#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

    ll n, q;
    cin >> n >> q;
    vector<ll> d(n), p(n), prs(n);
    for (ll i=0;i<n;i++) {
        cin >> d[i] >> p[i];
        if (i==0) prs[i]=p[i];
        else prs[i]=prs[i-1]+p[i];
    }
    while (q--) {
        ll k;
        cin >> k;
        ll idx = upper_bound(d.begin(), d.end(), k)-1-d.begin();
        cout << (idx==-1 ? "0\n" : to_string(prs[idx]-max(0LL, d[idx]+p[idx]-1-k))+"\n");
    }
    return 0;
}