#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 dk=n-j;
                if(bos-napadi[j].first-(tot*dk)<bos-napadi[j].second-(dk*(napadi[j].second+tot))){
                    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;
}