#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
    int n, q;
    cin >> n >> q;
    int d[n + 10];
    int p[n + 10];
    vector<int> dp[n + 10];
    for (int i = 0; i < n; i++) {
        cin >> d[i] >> p[i];
        if (p[i] == 0)
            continue;
        int poz = d[i] / p[i];
        dp[i + poz].push_back(i);
    }
    int poison = 0;
    vector<int> dmg;
    dmg.push_back(max(d[0], p[0]));
    if (p[0] >= d[0])
        poison += p[0];
    for (int i = 1; i < n; i++) {
        dmg.push_back(dmg[i - 1] + d[i] + poison);
        for (int x : dp[i]) {
            dmg[i] += p[x] * (i - x + 1) - d[x];
            poison += p[x];
        }
        if (dmg[i] >= 1000000000)
            break;
    }
    int h;
    while (q--) {
        cin >> h;
        auto it = lower_bound(dmg.begin(), dmg.end(), h);
        if (it == dmg.end())
            cout << -1 << '\n';
        else
            cout << (it - dmg.begin()) + 1 << '\n';
    }
    return 0;
}