#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];
    for (ll i=0; i<n; i++)
    {
        cin >> d[i] >> p[i];
        sumd[i+1]=sumd[i]+d[i];
    }
    for (ll i=1; i<=q; i++)
    {
        ll h; cin >> h;
        if (sumd[n]<h)
        {
            cout << -1 << endl;
            continue;
        }
        int l=1, r=n, mid;
        int ans=INT_MAX;
        while (l<=r)
        {
            mid=(l+r)/2;
            if (sumd[mid]>=h)
                ans=min(ans, mid);
            if (sumd[mid]>=h)
                r=mid-1;
            else
                l=mid+1;
        }
        cout << ans << endl;
    }
    return 0;
}