#include <bits/stdc++.h>

using namespace std;

long long p[200005], d[200005], hp[200005], umro[200005], otrovan[200005];

int n, q;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for(int i = 0; i < n; i++) cin >> d[i] >> p[i];
    while(q--) {
        long long hp, otrovan = 0, umro = -1;
        cin >> hp;
        for(int i = 0; i < n; i++) {
            if(p[i] == 0) hp -= d[i];
            if(hp <= 0) {
                umro = i + 1;
                break;
            }
        }
        cout << umro << "\n";
    }
}