#include <iostream>
using namespace std;

unsigned long long k[300000], d[300000], p[300000];
unsigned long long N, Q;

void ObradaUnosa()
{
    cin >> N >> Q;
    for (unsigned long long i = 0; i < N; i++) // Fixed index
    {
        cin >> d[i] >> p[i];
    }
}

unsigned long long UcitavanjeKi()
{
    unsigned long long ki;
    cin >> ki;
    return ki;
}

unsigned long long PosetaProdavnici(unsigned long long dan)
{
    for (unsigned long long i = 0; i < N; i++)
    {
        if (d[i] == dan)
        {
            return p[i];
        }
    }
    return 0;
}

void glavni(unsigned long long ki)
{
    unsigned long long ostava = 0;
    unsigned long long pojela = 0;
    for (unsigned long long dan = 0; dan < ki; dan++)
    {
        ostava += PosetaProdavnici(dan);

        if (ostava != 0)
        {
            ++pojela;
            --ostava;
        }
    }
    cout << pojela << endl;
}

int main()
{
    ObradaUnosa();
    for (unsigned long k = 0; k < Q; ++k)
    {
        unsigned long long ki = UcitavanjeKi();
        glavni(ki);
    }
    return 0;
}