#include <iostream>

using namespace std;

int main(){
int n,q;
cin >> n >> q;
int d[n],p[n];
for(int i=0;i<n;i++) cin >> d[i] >> p[i];
for(int i=0;i<q;q++){
    int hp;
    cin >> hp;
    int r;
    int ps=0;
    for(r=1;r<=n;r++){
        if(d[r-1]<=p[r-1]){
            ps+=p[r-1];
        }
        else hp-=d[r-1];
        hp-=ps;
        if(hp<=0) break;
    }
    if(hp>0 || r>n) cout << -1;
    else cout << r;
    cout << endl;
}
cout << endl;
return 0;
}