#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n, q, x, j, c, e;
	cin >> n >> q;
	long long d[n], p[n], k[q];
	for (long long i = 0; i < n; i++){
		cin >> d[i] >> p[i];
	}
	for (long long i = 0; i < q; i++){
		cin >> k[i];
	}
	for (long long i = 0; i < q; i++){
		x = 1;
		j = 0;
		c = 0;
		e = 0;
		while (x <= k[i]){
			if (d[j] == x){
				c += p[j];
				j++;
			}
			if (c > 0){
				c--;
				e++;
			}
			x++;
		}
		cout << e << "\n";
	}
}