#include <iostream>

using namespace std;

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