#include <bits/stdc++.h>

using namespace std;
void skip(long long int *i, long long int ddi, long long int ddk, long long int *tr,
          long long int *con, int ddp, int *di, int *dk)
{
    if (*tr == 0)
    {
        if ((ddi <= ddk) && (ddi != -1))
        {
            *i = ddi;
            *tr = ddp;
            (*di)++;
            (*con)++;
            (*tr)--;
        }
        if ((ddk <= ddi) || (ddi == -1))
        {
            *i = ddk;
            cout << *con<<"\n";
            (*dk)++;
        }
        return;
    }
    else
    {
        if (((ddi <= ddk) && (ddi <= *tr + *i)) && (ddi != -1))
        {
            *tr += ddp;
            *i = ddi;
            (*di)++;
        }
        if (((ddk <= ddi) && (ddk <= *tr + *i)) || ((ddi == -1) && (ddk <= *tr + *i)))
        {
            *con += ddk-*i;
            *tr -= ddk-*i;
            cout << *con<<"\n";
            (*dk)++;
        }
        if (((*tr + *i <= ddi) && (*tr + *i <= ddk)) || ((ddi == -1) && (ddk >= *tr + *i)))
        {
            *con += *tr;
            *i += *tr;
            *tr = 0;
        }
        return;
    }
}
int main()
{
    int n, q;
    cin >> n >> q;
    long long int tr = 0, con = 0, i = 0;
    vector<long long int> d(n + 1); // dan
    vector<int> p(n);               // kolicina
    vector<long long int> k(q + 1); // pitanja
    d[n] = -1;
    k[q] = -1;
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
        cin >> p[i];
    }
    for (int i = 0; i < q; i++)
        cin >> k[i];
    int dk = 0, di = 0;
    while (dk != q)
    {
        skip(&i, d[di], k[dk], &tr, &con, p[di], &di, &dk);
    }
}