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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    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];
    }

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

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

        auto it = upper_bound(dani.begin(), dani.end(), b);
        int idx = it - dani.begin() - 1;

        if (idx < 0) {
            cout << 0 << "\n";
            continue;
        }

        long long u = p[idx];
        long long r = b - dani[0] + 1;

        cout << min(u, r) << "\n";
    }

    return 0;
}