#include <bits/stdc++.h>

using namespace std;

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

    int n, q; cin >> n >> q;
    vector<pair<int, int>> 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--)
        {
            int c; cin >> c;
            int i = 0;
            while(c > 0 && i < n)
            {
                c -= napadi[i++].first;
            }
            if (c > 0)
                cout << -1 << endl;
            else
                cout << i << endl;
        }
    }
}