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

int main(){
    long long int N,Q,x,y,temp,dmg=0,ctr,ctr2,accu,resenje;   cin >> N >> Q;
    vector<int> D; vector<int> P; vector<int> H; vector<int> resenja;
    bool P0 = true;
    bool D0 = true;
    for(int i=0; i<N; i++){
        cin >> x >> y;
        if(y != 0){
            P0 = false;
        }
        if(x != 0){
            D0 = false;
        }
        dmg+=x;
        D.push_back(x);
        P.push_back(y);
    }
    for(int i=0; i<Q; i++){
        cin >> x;
        H.push_back(x);
    }

    for(int i=0; i<Q; i++){
            if(P0 == true){
                if(dmg < H[i]){
                    resenja.push_back(-1);
                }else{
                    ctr=0;
                    ctr2 = 0;
                    while(H[i]>0){
                        H[i] -= D[ctr2];
                        ctr++;
                        ctr2++;
                    }
                    resenja.push_back(ctr);
                }
            }else if(D0 && P0){
                resenja.push_back(-1);
            }else if(D0 == true){
                vector<int> pois;
                accu = 0;
                for(int j=0; j<N; j++){
                    H[i] -= (accu+P[j]);
                    accu+=P[j];
                    if(H[i]<=0){
                        pois.push_back(j+1);
                    }
                }
                if(pois.size() == 0){
                    resenja.push_back(-1);
                }else{
                resenja.push_back(pois[0]);
                }
            }


    }





    for(auto x: resenja){
        cout << x << endl;
    }
}