#include <iostream>

using namespace std;

int main(){
int n,q;
cin >> n >> q;
int d[n],p[n];
bool dmg[n];
int ps[n];
int sk[n];
for(int i=0;i<n;i++){
     cin >> d[i] >> p[i];
     if(i==0)ps[i]=0;
     else ps[i]=ps[i-1];
        if(d[i]<=p[i]){
            dmg[i]=false;
            ps[i]+=p[i];
            
        }
        //else if(d[r-1]<2*p[r-1] && hp>d[r-1]) dmg[i]=false;
        else dmg[i]=true;
        if(dmg[i]) sk[n]=d[i];
        else sk[n]=0;
        sk[n]+=ps[i];
}
for(int i=0;i<q;i++){
    int hp;
    cin >> hp;
    int j=0,m=n-1;
    if(sk[n-1]<hp){
        cout << -1 << endl;
        continue;
    }
    while(hp>sk[j] && hp<=sk[j+1]){
        int mid=(j+m)/2;
        if(hp<sk[j]) j=mid+1;
        else if(hp==sk[j]){
            cout << j+1;
            goto F;
        }
        else m=mid;
    }
    F:
    cout << endl;
}
cout << endl;
return 0;
}