#include <bits/stdc++.h>
#define MAXN 200005
#define INF 100000000000

using namespace std;
typedef long long ll;

ll N, Q;
ll D[MAXN], P[MAXN];
ll prefD[MAXN];
vector<ll> dp1(MAXN); // always direct
vector<ll> dp2(MAXN);
vector<ll> dp(MAXN);

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> Q;
    for (int i = 1; i <= N; i++)
    {
        cin >> D[i] >> P[i];
    }

    prefD[0] = D[0];
    for (int i = 0; i <= N; i++)
    {
        prefD[i] = prefD[i - 1] + D[i];
    }

    dp1[0] = dp2[0] = 0;
    ll acc1 = 0, acc2 = 0;

    for (int i = 1; i <= N; i++)
    {
        dp1[i] = dp1[i - 1] + acc1;
        if (D[i] > P[i])
        {
            dp1[i] += D[i];
        }
        else
        {
            dp1[i] += P[i];
            acc1 += P[i];
        }

        dp2[i] = dp2[i - 1] + acc2;

        dp1[i] = max(dp1[i], max(dp2[i] + D[i], dp2[i] + P[i]));

        if ((N - i) * P[i] >= D[i])
        {
            dp2[i] += P[i];
            acc2 += P[i];
        }
        else
        {
            dp2[i] += D[i];
        }
    }

    for (int i = 0; i <= N; i++)
    {
        dp[i] = max(dp1[i], dp2[i]);
        cout << i << ": " << dp1[i] << " " << dp2[i] << " " << dp[i] << "\n";
    }

    for (int q = 0; q < Q; q++)
    {
        ll H;
        cin >> H;

        auto it = lower_bound(dp.begin(), next(dp.begin(), N + 1), H);
        int d = distance(dp.begin(), it);
        if (d > N)
            d = -1;
        cout << d << "\n";
    }

    return 0;
}