#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<long long> days(N), packages(N);
    for (long long i = 0; i < N; ++i) {
        cin >> days[i] >> packages[i];
    }

    vector<long long> queries(Q);
    for (long long i = 0; i < Q; ++i) {
        cin >> queries[i];
    }

    for (long long i = 0; i < Q; ++i) {
        long long k = queries[i];
        long long total = 0;
        for (long long j = 0; j < N; ++j) {
            if (days[j] <= k) {
                total += packages[j];
            }
        }
        cout << total << "\n";
    }

    return 0;
}