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