#include <iostream>
#include <vector>

long long max(long long a, long long b) {
	if (a > b) return a;
	return b;
}

long long min(long long a, long long b) {
	if (a < b) return a;
	return b;
}


int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);

	int N, Q;
	std::cin >> N >> Q;

	int stock[N*2];
	for (int i = 0; i < N*2; i += 2)
		std::cin >> stock[i] >> stock[i+1];

	size_t used = 0;
	size_t has = 0;
	size_t last_day = 0; 

	int index = 0;
	size_t qu;
	for (int i = 0; i < Q; ++i) {
		std::cin >> qu;
		if (qu < stock[index*2]) {
			long long can_use = qu - last_day;
			used += min(has, can_use);
			has = max(0, has - can_use);
			last_day = qu;
			std::cout << used << "\n";
		} else {
			while(index < N && stock[index*2] < qu) {
				has += stock[index*2+1];
				long long can_use = stock[index*2] - last_day - 1;
				used += min(has, can_use);
				has = max(0, has - can_use);
				last_day = stock[index*2];
				index++;
			}
			long long can_use = qu - last_day;
			used += min(has, can_use);
			has = max(0, has - can_use);
			last_day = qu;
			std::cout << used << "\n";
		}
	}
	return 0;
}