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

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n, q;
    cin >> n >> q;

    vector<ll> d(n), p(n);
    for (int i = 0; i < n; i++) 
    {
        cin>> d[i] >>p[i];
    }

    vector<ll> k(q);
    for (int i = 0; i < q; i++) 
    {
        cin >> k[i];
    }

    for (int i = 0; i < q; i++) 
    {
        ll dx = k[i];
        ll pu = 0;
        ll ostalo = 0;
        for (int j = 0; j < n && d[j] <= dx; j++) 
        {
            ostalo += p[j];
            ll pdan;
			if (j + 1 < n) 
			{
    			pdan = min(dx, d[j + 1] - 1);
			} else 
			{
    			pdan = dx;
			}
            ll ukk = pdan - d[j] + 1;

            ll sad = min(ostalo, ukk);
            pu += sad;
            ostalo -= sad;
        }
        cout << pu << endl;
    }
    return 0;
}