#include <bits/stdc++.h>
using namespace std;
long long n,q, a[200007], p[200007], hp[200007],dp[200007],sol,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{
            for (int j=n;j>=1;j--){
                if (dp[j]>=hp[i] && dp[j]<=sol){
                    sol=dp[j];
                    ind=j;
                }
            }
        cout << ind << endl;
        }



    }




    return 0;
}