#include <bits/stdc++.h>
using namespace std;
using lol = long long;


void ispis(const vector<lol>& v)
{
    for (lol x : v){
        cout << x << endl;
    }
}
void pref(const vector<lol>& p, vector<lol>& s)
{
    s[0] = p[0];
    for (size_t i = 1; i < p.size(); i++) {
        s[i] = s[i - 1] + p[i];
    }
}
lol moew(const vector<lol>& d, const vector<lol>& p, const vector<lol>& s, lol k)
{
    int l = 0, r = d.size() - 1;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (d[mid] <= k) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    int x = r;
    if (x < 0) 
        return 0;
    lol t = s[x];
    lol e = max(0ll, (d[x] + p[x] - 1) - k); 
    return t - e;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<lol> d(n), p(n), s(n);
    for(int i = 0; i < n; ++i){
        cin >> d[i] >> p[i];
    }
    pref(p, s);
    vector<lol> k(q);
    for(int i = 0; i < q; ++i){
        cin >> k[i];
    }
    vector<lol> res(q);
    for(int i = 0; i < q; ++i){
        res[i] = moew(d, p, s, k[i]);
    }
    ispis(res);
    return 0;
}