#include <iostream>

using namespace std;

int main(){
long long int n,q;
cin >> n >> q;
long long int d[n],p[n];
bool dmg[n];
long long int ps[n];
long long int sk[n];
for(long long int i=0;i<n;i++){
     cin >> d[i] >> p[i];
     if(i==0) sk[i]=0;
     else sk[i]=sk[i-1];
     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 dmg[i]=true;
        if(dmg[i]) sk[i]+=d[i];
        sk[i]+=ps[i];
      //  cout << sk[i] << " " << ps[i] << endl;
}
for(long long int i=0;i<q;i++){
    long long int hp;
    cin >> hp;
    long long int j=0,m=n;
    if(sk[n-1]<hp){
        cout << -1 << endl;
        continue;
    }
    long long int res=n;
    if(sk[n-1]>=hp && sk[n-2]<hp) goto F;
     for(res=1;res<n;res=res){
        if(sk[res-1]>=hp) break;
        if(sk[res]<hp) res=(res+m)/2+1;
        else m=(res+m)/2;

     }
     F:
    cout << res;
    cout << endl;
}
cout << endl;
return 0;
}