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

#define ull unsigned long long

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n,q;
    cin >> n >> q;
    vector<ull> D(n,0);
    vector<ull> Q(n,0);
    bool cs1 = true, cs2 = true;
    for(int i = 0;i < n;i++){
        cin >> D[i] >> Q[i];
        if(Q[i] != 0) cs1 = false;
        if(D[i] != 0) cs2 = false;
    }

    if(cs1){
        sort(D.begin(),D.end());
        for(int i = 1;i < n;i++)
            D[i] += D[i-1];
        while(q--){
            int x;
            cin >> x;
            cout << (lower_bound(D.begin(),D.end(), x) - D.begin() == n ? -1 : lower_bound(D.begin(),D.end(), x) - D.begin()) << '\n';
        }
    }
    else if(cs2){
        sort(Q.begin(),Q.end());
        vector<ull> Q2(n,0);
        for(int i = 0;i < n;i++)
            for(int j = i;j < n;j++)
                Q2[j] += Q[i];

        while(q--){
            int x;
            cin >> x;
            cout << (lower_bound(Q2.begin(),Q2.end(), x) - Q2.begin() == n ? -1 : lower_bound(Q2.begin(),Q2.end(), x) - Q2.begin()) << '\n';
        }
    }

    return 0;
}