#include <bits/stdc++.h>
using namespace std;
long long n,q, a[200007], p[200007], hp[200007],dp[200007],sol,ind,best;
int bp(long long val){
    int l=0;
     int r=n;
    while (r>=l){
        int s=(l+r)/2;
        if (dp[s]>val){
            r=s-1;
            best=dp[s];
            ind=s;
        }
        else{
            l=s+1;
            best=dp[l];
            ind=l;

        }
    }
    return ind;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> q;
    for (int i=1;i<=n;i++){
        cin >> a[i] >> p[i];
        dp[i]=dp[i-1]+a[i];
    }
    for (int i=1;i<=q;i++){
        cin >> hp[i];
        sol=1e18;
        if (dp[n]<hp[i]) cout << -1 << endl;
        else{
            cout << bp(hp[i])+1 << endl;
            }
        }

    return 0;
}