#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    long long dmg[n], d[n], p[n], s = 0;
    dmg[0] = 0;
    vector<int> v[n];
    for (int i = 0; i < n; ++i) {
        v[i].clear();
        cin >> d[i] >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        //cout << i << endl;
        dmg[i] = dmg[i-1] + d[i] + s;
        if (p[i] != 0 || i-1 + (d[i] + p[i] - 1) / p[i] < n) {
            v[i - 1 + (d[i] + p[i] - 1) / p[i]].push_back(i);
        }
        if (!v[i].empty()) {
            for (int j = 0; j < v[i].size(); ++j) {
                dmg[i] -= d[v[i][j]];
                dmg[i] += p[v[i][j]] * (i - v[i][j] + 1);
                s += p[v[i][j]];
            }
        }
    }
    while (q--) {
        int h;
        cin >> h;
        if (dmg[n-1] < h) {
            cout << -1 << '\n';
            continue;
        }
        int l = 0, r = n-1, ans = n-1;
        while (l <= r) {
            int mid = (l + r)/2;
            if (dmg[mid] >= h) {
                r = mid-1,
                ans = mid;
            }
            else {
                l = mid+1;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}