#include <iostream>
#include <utility>
#include <vector>
#include <map>

using namespace std;

void pojela(unsigned long long dan, vector<pair<unsigned long long, unsigned long long> > dan_kol, int n){
	map<unsigned long long, unsigned long long> plazme;
	unsigned long long i = dan_kol[0].first - 1;
	unsigned long long brojac = 0;
	
	for(int i = 0; i < n; i++){
		unsigned long long j = dan_kol[i].first - 1;
		if(j < dan){
			plazme[j] = dan_kol[i].second;
		}
		else{ 
			break; 
		}
	}
	
	for(i; i < dan; i++){
		if(plazme[i] > 0){
			brojac++;
			plazme[i]--;
			if(i+1 < dan){
				plazme[i+1] += plazme[i];
			}
		}
//		for(int j = 0; j < dan; j++){
//			cout << plazme[j] << " ";
//		}
//		cout << endl;
//		cout << brojac << " " << i << endl;
	}
	cout << brojac << '\n';
}

int main(){
	int n, q;
	cin >> n >> q;
	vector<pair<unsigned long long, unsigned long long> > dan_kol(n);
	for(int i = 0; i < n; i++){
		cin >> dan_kol[i].first >> dan_kol[i].second;
	}
	unsigned long long dan;
	for(int i = 0; i < q; i++){
		cin >> dan;
		pojela(dan, dan_kol, n);
	}
	
	return 0;
}