#include <iostream>
using namespace std;
int main (void)
{
    unsigned long long int N,Q;
    cin>>N>>Q;
    unsigned long long int daniKupovine[N],plazmaKupljena[N];
    for (unsigned long long int i = 0; i < N; ++i)
        cin>>daniKupovine[i]>>plazmaKupljena[i];

    unsigned long long int upiti[Q];
    for (unsigned long long int i = 0; i < Q; ++i)
        cin>>upiti[i];
    unsigned long long int keks=0;
    unsigned long long int brojac=0,pojedeno[Q];
    unsigned long long int k;
    for(unsigned long long int i=0;i<=Q;++i)
    {
        k=upiti[i];
        brojac=0;
        for(unsigned long long int j=1;j<=k;++j)
        {
            for(unsigned long long int l=0;l<N;++l)
                if(daniKupovine[l]==j)
                    keks+=plazmaKupljena[l];
            if(keks>0)
            {
                --keks;
                ++brojac;
            }
        }
        pojedeno[i]=brojac;
        cout<<pojedeno[i]<<endl;
    }
}