#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];
        p=0;
        d=0;
        for (int j=0;j<N;j++)
        {
            if(P[j]*(os-j)>=D[j])
            {
                p=p+P[j];
                d=d+p;
            }
            else
                d=d+D[j]+p;


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

            while (d<H[i])
            { if (P[x]>=D[x])
                {p=p+P[x];
                d=d+p;}
                else if(d+D[x]+p<H[i]&&(2*P[x]>=D[x]))
                    {p=p+P[x];
                    d=d+p;}
                    else
                        d=d+D[x]+p;
                    pot++;
                    x++;



                }
            cout<<pot<<endl;
            }

        }


    return 0;
}