#include <iostream>

using namespace std;

int main()
{
   int N,x,Q;
    cin>>N;
    cin>>Q;
    int os=N,p,d,pot;
    int D[N],P[N],H[Q];
    for (int i=0;i<N;i++)
    {cin>>D[i];
    cin>>P[i];
    }
    for (int i=0;i<Q;i++)
        cin>>H[i];
    for (int i=0;i<Q;i++)
    {
    d=0;
    x=0;
        while(d<H[i]&&x<4)
        {

                d=d+D[x];
                x++;

        }
        if(H[i]>d)
            cout<<"-1"<<endl;
        else
        {
            cout<<x<<endl;

        }}

    return 0;
}