#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);
   for(int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
   }
   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) {
            r = mid - 1;
            ans = mid;
        }
        else {
            l = mid + 1;
        }
    }
    cout << ans << "\n";
   }
}