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

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