#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q;
    cin>>n>>q;
    vector<pair<int,int>>napadi;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        napadi.push_back(make_pair(a,b));
    }
    for(int i=0;i<q;i++){
        int bos;
        cin>>bos;
        int tot=0;
        int br=-1;
        for(int j=0;j<n;j++){
            if(napadi[j].second>=napadi[j].first){
                bos-=napadi[j].second;
                bos-=tot;
                tot+=napadi[j].second;
            }
            else{
                int bos3=bos;
                int bos2=bos;
                int br1=1;
                int br2=1;
                while(bos3>-1){
                    bos3-=napadi[j].first+(tot*br1);
                    br1++;
                }
                while(bos2>-1){
                    bos2-=napadi[j].second+(br2*(napadi[j].second+tot));
                    br2++;
                }
                if(br1<=br2){
                    bos-=napadi[j].first;
                    bos-=tot;
                }
                else{
                    bos-=napadi[j].second;
                    bos-=tot;
                    tot+=napadi[j].second;
                }

            }

            if(bos<=0){
                br=j+1;
                break;
            }

        }
       cout<<br<<endl;
    }
    return 0;
}