#include <bits/stdc++.h>

#define int long long

#define pb push_back

const int N = 2e5 + 10;

const int inf = 2e9;

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,q;
    cin >> n >> q;
    vector<int>p(n + 1),d(n + 1);
    for(int i = 1; i <= n; i++) cin >> d[i] >> p[i];
    while(q--) {
        int x;
        cin >> x;
        int l = 1,r = n,ans = -1;
        while(l <= r) {
            int mid = (l + r) / 2,X = 0;
            for(int i = 1; i <= mid; i++) {
                X += max(d[i],(mid - i + 1) * p[i]);
            }
            if(X >= x) {
                ans = mid;
                r = mid - 1;
            }else {
                l = mid + 1;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}