#include <iostream>

using namespace std;

int main(){
int n,q;
cin >> n >> q;
int d[n],p[n];
bool d0=true;
bool p0=true;
int od[n];
int op[n];
for(int i=0;i<n;i++){
    cin >> d[i] >> p[i];
    if(d[i]!=0) d0=false;
    if(p[i]!=0) p0=false;
    if(i!=0)od[i]=od[i-1]+d[i];
    else od[i]=d[i];
    if(i!=0)op[i]=p[i]+op[i-1]*2;
    else op[i]=p[i];
}
for(int i=0;i<q;i++){
    int hp;
    cin >> hp;
    if(d0 && p0) cout << -1 << endl;
    else if(d0){
        if(op[n-1]<hp) {
            cout << -1 << endl;
            continue;
        }
        for(int j=0;j<n;j++){
            if(op[j]>=hp){
                cout << j+1 << endl;
                break;
            }
        }
    }
    else if(p0){
        if(od[n-1]<hp) {
            cout << -1 << endl;
            continue;
        }
        for(int j=0;j<n;j++){
            if(od[j]>=hp){
                cout << j+1 << endl;
                break;
            }
        }
    }
    else {
    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;
}