#include <iostream>

using namespace std;
struct keks
{
    long long int nap,db;
};

int main()
{
    long long int n,m;
    cin>>n>>m;
    keks t[n];
    for (int i=0; i<n; i++)
    {
        cin>>t[i].nap>>t[i].db;
    }
    long long int counter=0,na,q,zabal;
    for (int i=0; i<m; i++)
    {
        zabal=0;
        counter=0;
        q=0;
        cin>>na;
        for (int j=0; j<na;j++)
        {
            if (t[q].nap-1==j)
                {
                    counter+=t[q].db;
                    q++;
                }
            if (counter!=0)
            {
                counter--;
                zabal++;
            }
        }
        cout<<zabal<<"\n";

    }

    return 0;
}