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

int main(){
	int n, q; cin >> n >> q;
	map<int, int> mapa;
	long long k[q];
	int maksi = 0;
	for(int i = 0; i < n; i++){
		int x, y; cin >> x >> y;
		mapa[x] = y;
		maksi = max(maksi, x);
	}
	int e = 0;
	while(q--){
		cin >> k[e];
		int zbir = 0, cnt = 0;
		for(int i = 1; i <= k[e]; i++){
			zbir+=mapa[i];
			if(zbir > 0){
				zbir--;
				cnt++;
			}
		}
		e++;
		cout<<cnt<<endl;
	}
}