#include <bits/stdc++.h>

using namespace std;

int main() {
    long long int n, q;
    cin >> n >> q;

    vector<long long int> dani(n);
    vector<long long int> plazme(n);
    vector<long long int> pitanja(q);

    for (int i = 0; i < n; ++i) {
        cin >> dani[i] >> plazme[i];
    }

    for (int j = 0; j < q; ++j) {
        cin >> pitanja[j];
    }

    vector<long long int> cplazme(n);
    cplazme[0] = plazme[0];
    for (int i = 1; i < n; ++i) {
        cplazme[i] = cplazme[i - 1] + plazme[i];
    }

    for (int j = 0; j < q; ++j) {
        int k = pitanja[j];
        long long int totalEaten = 0;
        for (int i = 0; i < n && dani[i] <= k; ++i) {
            totalEaten += min(plazme[i], k - dani[i] + 1);
        }
        cout << totalEaten << endl;
    }

    return 0;
}