#include <stdio.h>

int main()
{
	unsigned int n, q, k = 0, kk = 0;
	//int br = -1;
	scanf("%d %d", &n, &q);
	long int h[n][2];
	long int odgovori;
	long int pitanja[q];
	for (int i = 0; i < n; i++) {
		scanf("%ld %ld", &h[i][0], &h[i][1]);
	}
	for (int i = 0; i < q; i++){
	    scanf("%ld", &pitanja[i]);
	}

	unsigned int ima = 0;
	unsigned dan = 0;
	for (int i = 0; i < q; i++) {
	    kk = k;
		k = pitanja[i];
		for (int j = kk; j < k; j++) {
		    if ((j + 1) == (h[dan][0])) {
				ima += h[dan][1];
				dan += 1;
			}
			if (ima > 0) {
				ima -= 1;
				odgovori += 1;
			}
			//printf("%d ", ima);
		}
		printf("%ld \n", odgovori);
	}



	return 0;
}