#include <iostream>
#include <vector>
#include <climits>
#include <map>

using namespace std;

int main() {
    int n, q, temp2;
    long long temp1, s, r, t;
    cin >> n >> q;
    long long k[q];
    map<long long, long long> dp;
    for(int i = 0; i < n; i++) { cin >> temp1 >> temp2; dp[temp1] = temp2;}
    int maxi = dp.rbegin()->first;
    for(int i = 0; i < q; i++) cin >> k[i];
    for(int i = 0; i < q; i++) {
        r = 0;
        s = 0;
        (k[i] > maxi) ? t = maxi : t = k[i];
        for(long long j = dp.begin()->first; j <= t; j++) {
            if(dp.find(j) != dp.end()) {
                s += dp[j];
            }
            if(s > 0) {
                r++;
                s--;
            }
        }
        if(k[i] > maxi && s > 0) {
            long long razlika = k[i] - maxi;
            (razlika > s) ? r += s : r += razlika;
        }
        cout << r << endl;
    }

    return 0;
}