#include <bits/stdc++.h>

using namespace std;
using ll = long long;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    ll d[n+2], p[n+2]; d[0] = 0, d[n+1] = 2e18;
    for (int i = 1; i <= n; ++i) {
        cin >> d[i] >> p[i];
    }
    ll i = 1, K = 0, S = 0, c = 0;
    while (q--) {
        ll k;
        cin >> k;
        while (d[i] <= k) {
            S += min(d[i] - 1 - K, c);
            c -= min(d[i] - 1 - K, c);
            c += p[i];
            K = d[i] - 1;
            ++i;
        }
        S += min(k - K, c);
        c -= min(k - K, c);
        K = k;
        cout << S << '\n';
    }
}