#include <stdio.h>
#include <stdlib.h>

#define MAX_N 100000
#define MAX_M 100000

// Function to handle the operations
int main() {
    int N, M;
    scanf("%d", &N);  // Read number of servers

    if (N < 1 || N > MAX_N) {
        printf("Invalid input\n");
        return 0;
    }

    long long priority[MAX_N], load[MAX_N];  // Arrays to store the priorities and loads of servers

    // Read the priority and load of each server
    for (int i = 0; i < N; i++) {
        scanf("%lld %lld", &priority[i], &load[i]);
        
        // Check for invalid input
        if (priority[i] < 0 || priority[i] > 1000000000 || load[i] < 0 || load[i] > 1000000000) {
            printf("Invalid input\n");
            return 0;
        }
    }

    scanf("%d", &M);  // Read the number of incoming requests

    if (M < 1 || M > MAX_M) {
        printf("Invalid input\n");
        return 0;
    }

    // Process each incoming request
    for (int i = 0; i < M; i++) {
        long long minWeight = _LONG_LONG_MAX_;  // Initialize the minimum weight to a very large value
        int minServerID = -1;

        // Find the server with the smallest weighted load
        for (int j = 0; j < N; j++) {
            long long currentWeight = priority[j] * load[j];  // Calculate the weighted load

            if (currentWeight < minWeight || (currentWeight == minWeight && j < minServerID)) {
                minWeight = currentWeight;
                minServerID = j;
            }
        }

        // Print the selected server's ID (1-indexed)
        printf("%d ", minServerID + 1);
        load[minServerID]++;  // Increment the load of the selected server
    }

    printf("\n");
    return 0;
}