#include <iostream>
#include <vector>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    vector<pair<int, long long>> c(a); 
    for (int d = 0; d < a; ++d) {
        cin >> c[d].first >> c[d].second;
    }

    vector<long long> e(b);
    for (int d = 0; d < b; ++d) {
        cin >> e[d];
    }

    vector<long long> f(b);
    long long g = 0;
    long long h = 0;
    int i = 0;
    size_t j = 0;

    for (size_t d = 0; d < b; ++d) {
        long long k = e[d];

        while (i < k) {
            i++;

            while (j < c.size() && c[j].first == i) {
                g += c[j].second;
                j++;
            }

            if (g > 0) {
                h++;
                g--;
            }
        }

        f[d] = h;
    }

    for (size_t d = 0; d < b; ++d) {
        cout << f[d] << endl;
    }

    return 0;
}