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

using namespace std;
typedef long long ll;

ll N, Q;
ll D[MAXN], P[MAXN];
vector<ll> dp(MAXN);

namespace case1
{
    void solve()
    {
        for (int i = 1; i <= N; i++)
        {
            dp[i] = dp[i - 1] + D[i];
        }
    }
}

namespace case2
{
    void solve()
    {
        ll acc = 0;
        for (int i = 1; i <= N; i++)
        {
            dp[i] = dp[i - 1] + acc + P[i];
            acc += P[i];
        }
    }
}

namespace solution
{
    void solve()
    {
    }
}

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

    cin >> N >> Q;
    int c1 = 1, c2 = 1;
    for (int i = 1; i <= N; i++)
    {
        cin >> D[i] >> P[i];
        if (D[i] != 0)
            c2 = 0;
        if (P[i] != 0)
            c1 = 0;
    }

    dp[0] = 0;

    if (c1)
    {
        case1::solve();
    }
    else if (c2)
    {
        case2::solve();
    }
    else
    {
        solution::solve();
    }
    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;
}