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

int main()
{
	long long n = 0, q = 0, msum = 0;
	cin >> n >> q;
	vector<long long> dan(n+1);
	vector<long long> pla(n+1);
	vector<long long> pit(q);
	dan[0] = 1;
	pla[0] = 0;

	for (long long a = 1; a <= n; a++)
	{
		cin >> dan[a] >> pla[a];
		msum += pla[a];
	}
	for (long long a = 0; a < q; a++)
		cin >> pit[a];

	long long sum = 0;
	vector<long long> gap(n+1);
	for (int i = 1; i <= n; i++)
	{
		sum += pla[i-1] + dan[i-1];
		gap[i] += dan[i] - sum;
		if (gap[i] <= 0)
			gap[i] = 0;
		else
			sum -= pla[i - 1];
		sum -= dan[i - 1];
	}
	gap.erase(gap.begin() + 0);
	dan.erase(dan.begin() + 0);
	for (int i = 0; i < q; i++)
	{
		long long broj = pit[i], sum1 = 0, cnt = 0;
		while (cnt < gap.size() && dan[cnt] <= broj)
		{
			sum1 += gap[cnt];
			cnt++;
		}
		if (broj == pit[i] - sum1)
			cout << "0" << endl;
		else if (broj > dan[dan.size() - 1] * dan[dan.size() - 1])
			cout << msum << endl;
		else
			cout << pit[i] - sum1 << endl;
	}

	return 0;
}