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


int n, d[MAXN], p[MAXN];
int h;

bool check(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 solve(){
    cin >> h;
    int l = 0, r = n+1, mid, k=-1;
    while(l != r){
        mid = l+(r-l)/2;
        if(check(mid)){
            k = mid;
            r = mid;
        }
        else{
            l = mid+1;
        }

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


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];
    }
    while(q--){
        solve();
    }
    return 0;
}