#include <bits/stdc++.h>

using namespace std;

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

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

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

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

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

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

    return 0;
}