#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,q,a,b,di;
    vector <int> d,p,h;
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        cin >> a >> b;
        d.push_back(a);
        p.push_back(b);
    }
    for (int i = 0; i < q; i++){
        cin >> a;
        h.push_back(a);
    }
    for (int i = 0; i < q; i++){
        di=0;
        for(int j = 0; j < n; j++){
            di+=d[j];
            if (h[i]<=di){
                cout << j+1 << endl;
                break;
            }
        }
        if (h[i]>di){
            cout << -1 << endl;
        }
    }
    return 0;
}