#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> att, poi;
bool check(ll m, ll tar){
    ll sum = 0;
    for(int i = 0; i < m; ++i)
        sum += max(att[i], poi[i] * (m - i));
    if(sum >= tar)
        return 1;
    else
        return 0;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n, q; cin >> n >> q;
    ll attcnt = 0;
    att.resize(n); poi.resize(n);
    for(ll i = 0; i < n; ++i)
        {cin >> att[i] >> poi[i]; if(att[i]) attcnt++;}
    if(q <= 10){
        while(q--){
            ll l = 1, r = n, h, ans = -1;
            cin >> h;
            while(l <= r){
                ll mid = l + (r - l) / 2;
                if(check(mid, h)){
                    ans = mid;
                    r = mid - 1;
                }
                else{
                    //ans = mid;
                    l = mid + 1;
                }
            }  //cout << -1 << '\n';
           cout << ans << '\n';
        }
        return 0;
    }
    vector<ll> prefdag(n), prefpoi(n);
    prefdag[0] = att[0];
    for(ll i = 1; i < n; ++i)
        prefdag[i] = prefdag[i - 1] + att[i];
    prefpoi[0] = poi[0]; ll cur = poi[0];
    for(ll i = 1; i < n; ++i){
        cur += poi[i];
        prefpoi[i] = prefpoi[i - 1] + cur;
    }
    while(q--){
        ll h; cin >> h;
        if(!attcnt) {
            if(prefpoi[n - 1] < h)
                cout << -1 << '\n';
            else
                cout << lower_bound(prefpoi.begin(), prefpoi.end(), h) - prefpoi.begin() + 1 << '\n';
        } else{
            if(prefdag[n - 1] < h)
                cout << -1 << '\n';
            else
                cout << lower_bound(prefdag.begin(), prefdag.end(), h) - prefdag.begin() + 1 << '\n';
        }
    }
    return 0;
}