#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;
	map<int, int> m;
	vector<int> dani;
	for (int i = 0;i < n;i++) {
		int a, b; cin >> a >> b;
		m[a] += b;
		dani.push_back(a);
	}
	int brojilac = 0;
	int plazma = 0;
	int pojedeno = 0;
	while (q--) {
		int k;cin >> k;
		if (dani.back() <= k) {

		}
		else {
			for (int i = brojilac;dani[i] <= k;i++) {
				plazma += m[dani[i]];
				if (i == 2) {

				}
				if (dani[i + 1] > k) {
					plazma -= min(plazma,k - dani[i] + 1);
					pojedeno += min(plazma, k - dani[i] + 1);
				}
				
				
			}
		}
		cout << pojedeno << "\n";
	}

}
/*
2
1
1 6
5 3
6

*/