#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, q; cin >> n >> q;
    vector<ll> a(n), b(n);
    bool pk = true, dk = true;
    cin >> a[0] >> b[0];
        if (a[0] != 0)
            dk = false;
        if (b[0] != 0)
            pk = false;
    for (ll i = 1; i < n; i++)
    {
        cin >> a[i] >> b[i];
        a[i] += a[i - 1];
        b[i] += b[i - 1];
        if (a[i] != 0)
            dk = false;
        if (b[i] != 0)
            pk = false;
    }
    if (pk)
    {
        while(q--)
        {
            ll x; cin >> x;
            auto itr = lower_bound(a.begin(), a.end(), x);
            if (*itr >= x)
            {
                cout << distance(begin(a), itr) + 1 << endl;
            } else
                cout << -1 << endl;
        }
    }
    if (dk)
    {
        while(q--)
        {
            ll x; cin >> x;
            bool ok = false;
            for (int i = 0; i < n; i++)
            {
                x -= b[i];
                if (x <= 0)
                {cout << i + 1 << endl; ok = true; break;}
            }
            if (!ok)
                cout << -1 << endl;
        }
    }
}