#include <iostream>
#include <vector>


using namespace std;

int main() {
	long long N, Q;
	cin >> N >> Q;
	vector<unsigned long long> d, p;
	d.reserve(N + 1);
	p.reserve(N + 1);
	unsigned long long i_day = 0, day_now = 1;

	unsigned long long di, pi;
	for (size_t _ = 0; _ != N; ++_) {
		cin >> di >> pi;
		d.push_back(di);
		p.push_back(pi);
	}

	d.push_back(1e19);
	p.push_back(0);

	unsigned long long eaten_plazma = 0, left_plazma = 0, plazma_eaten_to_next, k;

	for (unsigned long long _ = 0; _ != Q; _++) {
		cin >> k;
		k++;
		while (day_now != k) {
			if (day_now == d[i_day])  // buy plazma
				left_plazma += p[i_day++];
			plazma_eaten_to_next = min(min(k - day_now, d[i_day] - day_now), left_plazma);
			eaten_plazma += plazma_eaten_to_next;
			left_plazma = max(unsigned long long(0), left_plazma - plazma_eaten_to_next);  // eat plazma
			day_now = min(k, d[i_day]);
		}
		cout << eaten_plazma;
	}

	return 0;
}