#include <bits/stdc++.h>

#define int long long

using namespace std;

signed 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) {
        vector<int> pref(n + 1, 0);
        for(int i = 1; i <= n; i++) {
            pref[i] = pref[i - 1] + a[i].first;
        }
        while(q--) {
            int x;
            cin >> x;
            int l = 1, r = n, ans = - 1;
            while(l <= r) {
                int mid = (l + r) / 2;
                if(pref[mid] >= x) {
                    r = mid - 1;
                    ans = mid;
                }
                else {
                    l = mid + 1;
                }
            }
            cout << ans << "\n";
        }
        return 0;
   }
   if(q <= 10) {
        
   }
}
// max((mid - i + 1) * a[i].second, a[i].first)