#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n,q;
    cin>>n>>q;
    vector<ll> max_dmg(n+1,0),poison_tick_add(n+1,0),poison_overtake(n+1,0);
    ll poison_tick=0;
    for (int i=1;i<=n;i++){
        poison_tick+=poison_tick_add[i];
        ll k=0,poison_dmg,phys_dmg;
        cin>>phys_dmg>>poison_dmg;
        if (poison_dmg>=phys_dmg){
            poison_tick+=poison_dmg;
            max_dmg[i]+=max_dmg[i-1]+poison_tick+poison_overtake[i];
        //    cout<<"posion_tick "<<i<<" "<<poison_tick<<"  "<<k<<'\n';
            continue;
        }
        else if (poison_dmg!=0){
            k=phys_dmg/poison_dmg;
         //   if (phys_dmg%poison_dmg!=0) k++;
            if (i+k<=n){
                poison_tick_add[i+k]+=poison_dmg;
                poison_overtake[i+k]+=(poison_dmg*k-phys_dmg);
            }
        }
        max_dmg[i]+=max_dmg[i-1]+poison_overtake[i]+poison_tick+phys_dmg;
      //  cout<<"posion_tick "<<i<<" "<<poison_tick<<"  "<<k<<'\n';
    }

 /*   for (int i=0;i<=n;i++){
        cout<<max_dmg[i]<<'\n';
    }
    for (int i=0;i<=n;i++) cout<<poison_tick_add[i]<<" ";
    cout<<'\n';
    for (int i=0;i<=n;i++) cout<<poison_overtake[i]<<" ";
    cout<<'\n';
 */   while(q--){

        ll hp;
        cin>>hp;
        ll rez=distance(max_dmg.begin(),lower_bound(max_dmg.begin(),max_dmg.end(),hp));
        if (rez>n) cout<<"-1\n";
        else cout<<rez<<'\n';
    }

    return 0;
}