#include<bits/stdc++.h>

using namespace std;

#define int long long

void solve(){
    int n, q;cin>>n>>q;
    vector<int> d(n), p(n), delta(n, 0), delta2(n);
    int cur = 0;
    for(int i = 0;i<n;i++){
        cin>>d[i]>>p[i];
        if(p[i]==0) continue;
        int r = d[i]/p[i];
        if(i+r<n){
            delta[i+r]+=(r+1)*p[i]-d[i];
            delta2[i+r]+=p[i];
        }
    }
    vector<int> pref(n+1);
    pref[0] = 0;
    for(int i = 0;i<n;i++){
        pref[i+1] = pref[i]+d[i]+delta[i]+cur;
        cur+=delta2[i];
    }
    for(int i = 0;i<q;i++){
        int h;cin>>h;
        int j = lower_bound(pref.begin(), pref.end(), h)-pref.begin();
        if(j==n+1) cout<<-1<<endl;
        else cout<<j<<endl;
    }
    return;
}

int32_t main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}