#include <iostream> 
#include <map>
using namespace std;
map <unsigned long long, unsigned> Nabavka;
map <unsigned long long, unsigned>::iterator it, pom;
unsigned long long ispis[300000];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	unsigned n, q = 300000, p;
	unsigned long long d, k = 0;
	
	cin >> n >> q;

	for (int i = 0; i < n; i++) {
		cin >> d >> p;
		Nabavka.insert(make_pair(d, p));
	}
	
	it = Nabavka.begin();
	pom = it;
	pom++;

	it = Nabavka.begin();
	
	
	
	for (int j = 0; j < q; j++) {
		unsigned long long br_pojedenih = 0;
		cin >> k;

		if (!Nabavka.empty() && k >= it->first) {
			unsigned long long ostatak = 0;
			
			while (it != Nabavka.end() && it->first <= k) {
				
				unsigned long long trenutna_vr = it->second + ostatak; 
				
				if (trenutna_vr >= k - it->first + 1) {
					br_pojedenih += k - it->first + 1;
					ostatak += trenutna_vr - br_pojedenih;
					break;
				} else {
					br_pojedenih += it->second;
					ostatak = 0;
				}
				pom = it;
				it = Nabavka.erase(pom);
			} 
			//if (ostatak != 0) it = pom;
			ispis[j] = br_pojedenih;
		} else ispis[j] = 0;
	}

	for (int j = 0; j < q; j++) cout << ispis[j] << "\n";
	return 0;
}