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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,q;
    cin >> n >> q;
    vector<long long> dan(n);
    vector<long long> kol(n);
    for(int i = 0;i < n;i++){
        long long d,p;
        cin >> d >> p;
        dan[i] = d;
        if(i == 0) kol[0] = p;
        else kol[i] = kol[i-1]+p;
    }

    while(q--){
        long long k;
        cin >> k;
        long long fnd = lower_bound(begin(dan),end(dan),k) - begin(dan);
        if(fnd == 0) {
            cout << "0\n";
        }
        else{
            fnd--;
            long long res = 0;
            if(fnd > 0) res = kol[fnd-1];

            if(min(k-dan[fnd] + 1,kol[fnd]) == kol[fnd]) cout <<  kol[fnd] << '\n';
            else cout << k - dan[fnd] + 1 + res << '\n';
        }
    }
}