#include <iostream>
#include <vector>
using namespace std;

int main()
{
    unsigned int N, Q, pomp, l = 0, br_pakovanja = 0;
    vector<unsigned int> p;
    unsigned long long int pomdk, suma_pakovanja = 0;
    vector<unsigned long long int> d, k;

    do{
        //cout << "Unesite broj pronalazenja plazme (N): ";
        cin >> N;
    }while(N < 0 || N > 300000);
    do{
        //cout << "Unesite broj pitanja (Q): ";
        cin >> Q;
    }while(Q < 0 || Q > 300000);

    for(int i = 0; i < N; i++){
        //cout << "Unesite dan i koliko je pakovanja nadjeno tog dana (d i p): ";
        do{
            cin >> pomdk >> pomp;
        }while(pomdk < 1 || pomdk > 1e18 || pomp < 0 || pomp > 1e9);
        d.push_back(pomdk);
        p.push_back(pomp);
    }
    for(int i = 0; i < Q; i++){
        //cout << "Unesite pitanja (k): ";
        do{
            cin >> pomdk;
        }while(pomdk < 1 || pomdk > 1e18);
        k.push_back(pomdk);
    }

    for(int i = 0; i < Q; i++){
        for(int j = 0; j <= k[i]; j++){
            if(j == d[l]){
                suma_pakovanja += p[l];
                l++;
            }
            if(suma_pakovanja > 0){
                suma_pakovanja--;
                br_pakovanja++;
            }
        }
        k[i] = br_pakovanja;
    }
    for(int i =0; i < Q; i++){
        cout << k[i] << '\n';
    }

    return 0;
}