#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
long long d[300001], p[300001], k[300001];
int main()
{
    long long n, q;
    cin >> n >> q;
    for (long long i = 0; i < n; i++)
    {
        cin >> d[i] >> p[i];
    }
    for (long long j = 0; j < q; j++)
    {
        cin >> k[j];
    }
    long long i = 0, plazma = 0, m = d[0]-1;
    for (long long j = 0; j < q; j++)
    {
        while (m < k[j] && i < n && d[i] <= k[j])
        {
            m = max(m, d[i]-1);
            if (p[i] == 0) i++;
            else if (p[i] < k[j]-m)
            {
                plazma += p[i];
                m += p[i];
                p[i] = 0;
                i++;
            }
            else
            {
                plazma += k[j]-m;
                p[i] -= k[j]-m;
                m = k[j];
                break;
            }
        }
        cout << plazma << endl;
    }
    return 0;
}