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

int main()
{
    int n,q,a,b;
    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(b);
    }
    for (int i = 0; i < q; i++){
        for(int j = 0; j < n; i++){
            h[i]-=d[i];
            if (h[i]<=0){
                cout << j << endl;
                break;
            }
        }
        if (h[i]>0){
            cout << -1 << endl;
        }
    }
    return 0;
}