#include<iostream>
#include<map>
#include<vector>
#define int long long
using namespace std;
signed main() {
	ios_base::sync_with_stdio(false);
	int n, q;cin >> n >> q;
	vector<int> dani(300001,0);
	for (int i = 0;i < n;i++) {
		int a, b; cin >> a >> b;
		dani[a] += b;
	}
	vector<int> resenja;
	while (q--) {
		int k;cin >> k;
		resenja.push_back(k);
	}
	int brojilac = 0;
	int plazma = 0;
	int pojedeno = 0;
	for (int i = 1; i <= 300000 && brojilac < resenja.size();i++) {
		plazma += dani[i];
		if (plazma > 0) {
			plazma--;
			pojedeno++;
		}
		if (i == resenja[brojilac]) {
			cout << pojedeno << "\n";
			brojilac++;
		}
	}

}