#include <bits/stdc++.h>

#define int long long

#define pb push_back

#define F first

#define S second

const int N = 2e5 + 10;

const int inf = 2e9;

using namespace std;

vector<int>in[N];
int res[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,q;
    cin >> n >> q;
    vector<int>p(n + 1),d(n + 1);
    for(int i = 1; i <= n; i++) cin >> d[i] >> p[i];
    vector<int>c(n + 1);
    for(int i = 1; i <= n; i++) {
        int l = i,r = n,ans = n + 1;
        while(l <= r) {
            int mid = (l + r) / 2;
            if((mid - i + 1) * p[i] >= d[i]) {
                ans = mid;
                r = mid - 1;
            }else {
                l = mid + 1;
            }
        }
        if(ans != i) in[ans].pb(i);
    }
    vector<pair<int,int>>kveri(q + 1);
    for(int i = 1; i <= q; i++) {
        int x;
        cin >> x;
        kveri[i].F = x;
        kveri[i].S = i;
    }
    sort(kveri.begin() + 1,kveri.end());
    int ptr = 0,sum = 0,sumP = 0;
    for(int i = 1; i <= q; i++) {
        while(ptr + 1 <= n && sum < kveri[i].F) {
            sum += sumP;
            sum += max(d[ptr + 1],p[ptr + 1]);
            if(p[ptr + 1] >= d[ptr + 1]) sumP += p[ptr + 1];
            ptr += 1;
            for(auto X : in[ptr]) {
                sum -= d[X];
                sum += (ptr - X + 1) * p[X];
                sumP += p[X];
            }
        }
        if(sum >= kveri[i].F) res[kveri[i].S] = ptr;
        else res[kveri[i].S] = -1;
    }
    for(int i = 1; i <= q; i++) cout << res[i] << "\n";
    return 0;
}