#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    bool Dk_0 = true;
    bool Pk_0 = true;

    int n, q; cin >> n >> q;
    vector<vector<int>> napadi(n, vector<int>(2));

    for (int i = 0; i < n; i++) {
        cin >> napadi[i][0] >> napadi[i][1];
        if (napadi[i][0] != 0)
            Dk_0 = false;
        if (napadi[i][1] != 0)
            Pk_0 = false;

        // Dk, Pk.
    }

    while (q--) {
        int broj_poteza = 0;
        int health;
        cin >> health;

        if (Pk_0) {
            for (int i = 0; i < n; i++) {
                health -= napadi[i][0];
                broj_poteza++;
                if (health <= 0)
                    break;
            }
        }
        if (health <= 0) {
            cout << broj_poteza << endl;
        }
        else {
            cout << -1 << endl;
        }
    }

    return 0;
}