#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;
    cin >> n >> q;
    vector <int> p(n);
    vector <int> h(q);
    vector <int> b(q, 0);
    for (int i = 0; i < n; i++){
        cin >> up >> p[i];
    }
    for (int i = 0; i < q; i++){
        cin >> h[i];
    }
    for (int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            h[i] -= p[j];
            b[i] += 1;
            if (h[i] <= 0){
                break;
            }
        }
        if (h[i] > 0){
            b[i] = -1;
        }
        cout << b[i] << '\n';
    }
    return 0;
}