#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define MOD 1000000007 // 998244353
#define FIO                \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);

int main()
{
	FIO
	ll n, q; cin >> n >> q;
	vector<ll> a(n), b(n), prefixSum(n+1);
	prefixSum[0] = 0;
	forn(i, n)
	{
		cin >> a[i] >> b[i];
		prefixSum[i+1] = b[i] + prefixSum[i];
	}
		
	sort(all(b));
	while(q--)
	{
		ll x; cin >> x;
		auto itr = upper_bound(all(a), x);
		if (itr == begin(a))
		{
			cout << 0 << endl;
			continue;
		}
		if (itr == end(a) || *itr > x)
			itr--;
		ll position = distance(begin(a), itr);
		//cout << position << endl;
		ll can_take = prefixSum[position];
		//cout << can_take << endl;
 		can_take += min(b[position], x - a[position] + 1);
		cout << can_take << endl;
	}
}