#include <bits/stdc++.h>

using namespace std;
int n, q;
vector<long long int> d;//d
vector<long long int> p;
int grubasila(int helt, long long pojzon, int brrr){
    if(brrr > n)return INT_MAX;
    if(helt <= 0)return brrr;
    return min(grubasila(helt-pojzon-d[brrr], pojzon, brrr+1), grubasila(helt-pojzon-p[brrr], pojzon+p[brrr], brrr+1));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;

    d.resize(n);
    p.resize(n);
    //kao dp kao hahahhahhhahahahhah. pozdrav za marka popovica.
    long long int ohajofajnalbos;
    bool slucd = true, slucp= true;
    for(int i = 0; i < n ; i++){
        cin >> d[i]  >> p[i];
        if(d[i] !=0)slucp = false;
        if(p[i] != 0)slucd = false;
    }
    if(slucd){
        vector<long long int> prefiksne(n);
        prefiksne[0] = d[0];
        for(int i = 1; i < n ; i++){
            prefiksne[i] = prefiksne[i-1]+d[i];
        }
        for(int i = 0; i < q; i++){
            cin >> ohajofajnalbos;
            if(lower_bound(prefiksne.begin(), prefiksne.end(), ohajofajnalbos) - prefiksne.begin() == n)cout << -1 << "\n";
            else cout << lower_bound(prefiksne.begin(), prefiksne.end(), ohajofajnalbos) - prefiksne.begin()+1 << "\n";
        }
        return 0;
    }
    if(slucp){
        vector<long long int> prefiksne(n);
        long long int suma = p[0];
        prefiksne[0] = p[0];
        for(int i = 1; i < n ; i++){
            prefiksne[i] = prefiksne[i-1]+p[i]+ suma;
            suma += p[i];
        }
        for(int i = 0; i < q; i++){
            cin >> ohajofajnalbos;
            if(lower_bound(prefiksne.begin(), prefiksne.end(), ohajofajnalbos) - prefiksne.begin() == n)cout << -1 << "\n";
            else cout << lower_bound(prefiksne.begin(), prefiksne.end(), ohajofajnalbos) - prefiksne.begin()+1 << "\n";
        }
        return 0;
    }
    for(int i = 0; i < q; i++){
        cin >> ohajofajnalbos;
        int rizz = grubasila(ohajofajnalbos, 0,0);
        if(rizz == INT_MAX)cout << -1 << "\n";
        else cout << rizz << "\n";
    }
    return 0;
}