#include <iostream>
#include <vector>

using namespace std;

void popuniNiz(std::vector<long long int>& niz) {
    for (long long int i = 0; i < niz.size(); ++i) {
        while (niz[i] > 1) {
            niz[i]--;
            niz[i + 1]++;

            if (i + 1 == niz.size()) {
                niz.push_back(0); 
            }
        }
    }
}

int main() {
    long long int N, Q;
    cin >> N >> Q;

    long long int maxDan = 0;  

    vector<long long int> rezultat;

    for (long long int i = 0; i < N; ++i) {
        long long int d, p;
        cin >> d >> p;
        
        if (d > maxDan) {
            maxDan = d;  
        }
        if (d > rezultat.size()) {
            rezultat.resize(d, 0);  
        }

        rezultat[d - 1] += p;
    }

    popuniNiz(rezultat);

    for (long long int i = 0; i < Q; ++i) {
        long long int k;
        cin >> k;

        long long int counter = 0;
        for (long long int i = 0; i < k; ++i) {
            counter += rezultat[i];
        }
        
        cout << counter << endl; 
    }

    return 0;
}