#include <iostream>

using namespace std;

typedef unsigned long long ull;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, q;
	cin >> n >> q;
	ull d1[n], p1[n];
	for(int i = 0; i < n; i++)
		cin >> d1[i] >> p1[i];
	ull k[q];
	for(int i = 0; i < q; i++)
		cin >> k[i];
	
	ull d[n+q+1], p[n+q+1];
	d[0] = 0; p[0] = 0;
	for(int i = 0, j = 0; i + j < n + q;) {
		if(i == n) {
			d[i+j+1] = k[j];
			p[i+j+1] = 0;
			j++;
		}else if(d1[i] <= k[j] || j == q) {
			d[i+j+1] = d1[i];
			p[i+j+1] = p1[i];
			i++;
		}else{
			d[i+j+1] = k[j];
			p[i+j+1] = 0;
			j++;
		}
	}
	
	
	ull preostalo = 0, pojedeno = 0;
	for(int i = 1; i <= n + q; i++) {
		pojedeno  += min(preostalo, d[i] - d[i-1]) + (p[i] > 0 && preostalo < d[i] - d[i-1]);
		preostalo -= min(preostalo, d[i] - d[i-1]) + (p[i] > 0 && preostalo < d[i] - d[i-1]) - p[i];
		
		if(p[i] == 0)
			cout << pojedeno << '\n';
	}
	
	return 0;
}