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

int main(){
    int N,Q,x,y,temp;   cin >> N >> Q;
    vector<int> D; vector<int> P; vector<int> H; vector<int> resenja;
    for(int i=0; i<Q; i++){
        cin >> x >> y;
        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(P[i] == 0){
            if(N*D[i]<H[i]){
                resenja.push_back(-1);
            }else{
                temp = H[i]/D[i];
                if(H[i] % D[i] != 0){
                    temp++;
                }
                resenja.push_back(temp);
            }
        }
    }
    for(auto x: resenja){
        cout << x << endl;
    }
}