#include <bits/stdc++.h>

using namespace std;

unsigned long long p[2000005], d[2000005], psum[2000005];

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++) {
        int tmp, tmp2;
        cin >> tmp >> tmp2;
        if(i == 0) {
            d[i] = tmp;
            p[i] = tmp2;
            psum[i] = tmp2;
        }
        else {
            d[i] = d[i - 1] + tmp;
            psum[i] = psum[i - 1] + tmp2;
            p[i] = psum[i] + p[i - 1];
        }
    }
    while(q--) {
        unsigned long long hp, otrovan = 0, umro = -1;
        cin >> hp;
        long long potez;
        if(p[0] == 0) {
            potez = upper_bound(d, d + n, hp) - d;
        }
        else if(d[0] == 0) {
            potez = upper_bound(p, p + n, hp) - p;
        }
        cout << (potez == n ? -1 : potez + 1) << '\n';
    }
}
/*
5 5
0 1
0 1
0 1
0 1
0 1
2 2 2 2 2
*/