#include <iostream>
#define ll long long
using namespace std;
ll sumd[200010];
int main()
{
    ll n, q;
    cin >> n >> q;
    ll d[n+10], p[n+10];
    bool p0=true;
    bool d0=true;
    for (ll i=0; i<n; i++)
    {
        cin >> d[i] >> p[i];
        if (p[i]!=0) p0=false;
        if (d[i]!=0) d0=false;
        sumd[i+1]=sumd[i]+d[i];
    }
    if (p)
    {
        for (ll i=0; i<q; i++)
        {
            ll h; cin >> h;
            if (sumd[n]<h)
            {
                cout << "-1" << endl;
                continue;
            }
            ll ans=n;
            for (ll i=1; i<=n; i++)
            {
                if (sumd[i]>=h)
                {
                    ans=i;
                    break;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}