#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<pair<ll, ll>> napadi(n);
    bool pk = false, dk = false;
    for (int i =0; i < n; i++)
    {
        cin >> napadi[i].first >> napadi[i].second;
        if (napadi[i].first != 0)
            dk = true;
        if (napadi[i].second != 0)
            pk = true;
    }
    if (!pk)
    {
        while(q--)
        {
            long long c; cin >> c;
            ll i = 0;
            while(c > 0 && i < n)
            {
                c -= napadi[i].first;
                i++;
            }
            if (c > 0)
                cout << -1 << endl;
            else
                cout << i << endl;
        }
    }
}