#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q, up;
    bool p0 = true;
    cin >> n >> q;
    vector <int> p(n);
    vector <int> d(n);
    vector <int> h(q);
    int b = 0;
    for (int i = 0; i < n; i++){
        cin >> d[i] >> p[i];
        if (p[i] != 0){
            p0 = false;
        }
    }
    for (int i = 0; i < q; i++){
        cin >> h[i];
    }
    if (p0 == true){
        for (int i = 0; i < q; i++){
            for(int j = 0; j < n; j++){
                h[i] -= d[j];
                b += 1;
                if (h[i] <= 0){
                    break;
                }
            }
            if (h[i] > 0){
                b = -1;
            }
            cout << b << '\n';
            b = 0;
        }
    }
    else{
        int s = p[0];
        for (int i = 0; i < q; i++){
            for (int j = 0; j < n; j++){
                h[i] -= s;
                if (j < n-1){
                    s += p[j+1];
                }
                b += 1;
                if (h[i] <= 0){
                    break;
                }
            }
            if (h[i] > 0){
                b = -1;
            }
            cout << b << '\n';
            b = 0;
        }
    }
    return 0;
}