#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, q;
    cin>>n>>q;
    vector <ll> d(n), p(n);
    for (ll i=0; i<n; i++)
    {
        cin>>d[i]>>p[i];
    }
    while (q--)
    {
        ll z;
        cin>>z;
        ll brp=0, prefo=0;
        for (int i=0; i<n; i++)
        {
            if (z<=0) break;
            prefo+=p[i];
            z-=prefo;
            brp++;
        }
        if (z>0) cout<<-1<<endl;
        else cout<<brp<<endl;
    }
    return 0;
}