#include <bits/stdc++.h>

using namespace std;

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, q;
   cin >> n >> q;
   vector<pair<int,int>> a(n + 1);
   int subtask = 1;
   for(int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    if(a[i].second != 0) {
        subtask = 0;
    }
   }
   if(! subtask) {
    return 0;
   }
   while(q--) {
    int x;
    cin >> x;
    int l = 1, r = n, ans = - 1;
    while(l <= r) {
        int mid = (l + r) / 2;
        int c = 0;
        int ok = 0;
        for(int i = 1; i <= mid; i++) {
            c += a[i].first;
            if(c >= x) {
                ok = 1;
                break;
            }
        }
        if(ok) {
            r = mid - 1;
            ans = mid;
        }
        else {
            l = mid + 1;
        }
    }
    cout << ans << "\n";
   }
}