#include <bits/stdc++.h>

using namespace std;

struct Kupovina{
    long long dan;
    long long plazma;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin >> n;
    int q;cin >> q;
    vector<Kupovina> kupovine(n);
    for(int i = 0; i < n; i++) {
        cin >> kupovine[i].dan >> kupovine[i].plazma;
    }
    vector<long long> upit(q);
    for(int i = 0; i < q;i++){
        cin >> upit[i];
    }
    vector<long long> paket(n + 1, 0);
    vector<long long> dani(n);         
    for(int i = 0; i < n;i++){
        paket[i + 1] = paket[i] + kupovine[i].plazma;
        dani[i] = kupovine[i].dan;
    }
    vector<long long> res(q);
    long long izedeno = 0;
    int ipaket = 0;
    for(int i = 0; i < q;i++) {
        long long k = upit[i];
        while (ipaket < n && dani[ipaket] <= k) {
            izedeno += min(k - dani[ipaket] + 1, kupovine[ipaket].plazma);
            ipaket++;
        }
        res[i] = izedeno;
    }
    for(int i = 0; i < res.size();i++) {
        cout << res[i] << "\n";
    }
    return 0;
}