#include <iostream>
#include <unordered_map>
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++) // Fix: Changed n++ to i++
    {
        cin >> d[i] >> p[i];
    }
}

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

unsigned long long PosetaProdavnici(unordered_map<unsigned long long, unsigned long long>& posete, unsigned long long dan)
{
    // Vracamo broj poseta na konkretan dan
    return posete[dan]; 
}

void glavni(unsigned long long ki)
{
    unordered_map<unsigned long long, unsigned long long> posete;
    for (unsigned long long i = 0; i < N; i++)
    {
        posete[d[i]] += p[i]; // Za svaki dan, dodajemo posetu u mapu
    }

    unsigned long long ostava = 0;
    unsigned long long pojela = 0;
    for (unsigned long long dan = 0; dan < ki; dan++)
    {
        ostava += PosetaProdavnici(posete, 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;
}