#include <vector>
#include <iostream>
using namespace std;


void DanTick(vector<pair<int, int>>& a, vector<int>& pitanjca, int N, int& BrojPakovanja, int& Dan, int& Pojedeno)
{
	Dan++;
	
	for (int i = 0; i < a.size(); i++)
	{
		if (a[i].first == Dan)
		{
			BrojPakovanja = BrojPakovanja + a[i].second;
		}
	}
	if (BrojPakovanja > 0)
	{
		BrojPakovanja--;
		Pojedeno++;
	}
	for (int i = 0; i < pitanjca.size(); i++)
	{
		if (pitanjca[i] == Dan)
		{
			cout << Pojedeno << endl;
		}
	}

}


int main()
{
	int BrojPakovanja = 0;
	int Dan = 0;
	int Pojedeno = 0;

	int N, Q;
	cin >> N >> Q;
	
	vector<pair<int, int>> a;
	vector<int> pitanjca;
	int x, y;
	for (int i = 0; i < N; i++)
	{
		cin >> x >> y;
		a.push_back({ x, y });
	}
	int pit;
	for (int i = 0; i < Q; i++)
	{
		cin >> pit;
		pitanjca.push_back(pit);
	}

	for (int i = 0; i < pitanjca[pitanjca.size()-1]; i++)
	{
		DanTick(a, pitanjca, N, BrojPakovanja, Dan, Pojedeno);
	}

	
	
	return 0;
}