#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N,D[200005],P[200005],Q,H,iskoristen[200005],suma;
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cin>>N>>Q;
     for(int i=1;i<=N;i++)cin>>D[i]>>P[i];
    while(Q--){
        suma=0;
        cin>>H;
        for(int i=1;i<=N;i++){
                if(suma+D[i]>=H){H-=suma;H-=D[i];cout<<i<<endl;break;}
            if(P[i]*(N+1-i)>D[i]){
                suma+=P[i];
            }
            else{
                H-=D[i];
            }
            H-=suma;
            if(H<1){
                 cout<<i<<endl;
                    break;
            }
        }
        if(H>0){
            cout<<-1<<endl;
        }
    }

return 0;
}