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

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

    vector<long long> dani(n);
    vector<long long> broj(n);

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

    for (int i = 0; i < q; i++) {
        long long b;
        cin >> b;

        long long u = 0;
        long long rezerve = 0;
        for (int j = 0; j < n; j++) {
            if (dani[j] > b) break;

            long long nd = (j == n - 1 ? b + 1 : min(dani[j + 1], b + 1));
            long long d = nd - dani[j];

            rezerve += broj[j];

            long long pojedeno = min(d, rezerve);

            u += pojedeno;
            rezerve -= pojedeno;
        }

        cout << u << endl;
    }

    return 0;
}