#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
int main()
{
    int n, q;
    cin>>n>>q;
    vector <int> d(n), p(n);
    for (int i=0; i<n; i++)
    {
        cin>>d[i]>>p[i];
    }
    while (q--)
    {
        int z;
        cin>>z;
        int brp=0, prefo=0;
        for (int i=0; i<n; i++)
        {
            if (z<=0) break;
            z-=max(d[i]+prefo, prefo+p[i]);
            if (prefo+p[i]>d[i]+prefo)
            {
                prefo+=p[i+1]*(i<n-1);
            }
            brp++;
        }
        if (z>0) cout<<-1<<endl;
        else cout<<brp<<endl;
    }
    return 0;
}