#include <iostream>
#include <vector>
using namespace std;
int f(long long k, const vector<long long>& a, const vector<long long>& x) {
    int j = 0, suma = 0, pojedeno = 0;
    for (long long i = 1; i <= k; i++) { 
        if (j < a.size() && i == a[j]) {
            suma += x[j];
            j++; 
        }
        if (suma > 0) {
            pojedeno++;
            suma--;
        }
    }
    return pojedeno;
}

int main() {
    int n, q;
    cin >> n >> q;

    vector<long long> a(n), x(n), k(q);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> x[i];
    }
    for (int i = 0; i < q; i++) {
        cin >> k[i];
    }
    for (int i = 0; i < q; i++) {
        cout << f(k[i], a, x) << endl;
    }

    return 0;
}