#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int inf = 2147483647;


int n, d[MAXN], p[MAXN];
int h;
long long sp, sd;

void solve1(){
    cout << "1\n";
}
void solve2(){
    cout << "2\n";
}

bool check3(int k){
    long long s = 0ll, t;
    for(int i = 0; i < k; ++i){
        t = 1ll*p[i]*(k-i);
        s += max(t, (long long)d[i]);
    }
    return s >= h;
}
void solve3(){
    int l = 0, r = n+1, mid, k=-1;
    while(l != r){
        mid = l+(r-l)/2;
        if(check3(mid)){
            k = mid;
            r = mid;
        }
        else{
            l = mid+1;
        }

    }
    cout << k << '\n';
}


void solve(){
    if(sp == 0) solve1();
    else if(sd == 0) solve2();
    else solve3();
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int q;
    cin >> n >> q;
    for(int i = 0; i < n; ++i){
        cin >> d[i] >> p[i];
        sd += d[i];
        sp += p[i];
    }
    while(q--){
        cin >> h;
        solve();
    }
    return 0;
}