#include <bits/stdc++.h>

using namespace std;

struct potez{int d, p;};

potez potezi[200005];

int hp[200005], umrli[200005], otrovi[200005];

int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> potezi[i].d >> potezi[i].p;
    for(int i = 0; i < k; i++) cin >> hp[i];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < k; j++) {
            if(hp[j] <= 0) continue;
            umrli[j]++;
            if(potezi[i].d == 0) otrovi[j] += potezi[i].p;
            if(potezi[i].p == 0) hp[j] -= potezi[i].d;
            hp[j] -= otrovi[j];
            if(hp[j] <= 0) {
                umrli[j] = i;
                continue;
            }
        }
    }
    for(int i = 0; i < k; i++) {
        if(hp[i] > 0) cout << -1 << "\n";
        else cout << umrli[i] + 1 << "\n";
    }
}