#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, q;
    cin >> n >> q;
    vector <long long> d(n+1);
    vector <int> p(n);
    vector <long long> k(q);
    vector <long long> r(q, 0);
    for (int i = 0; i < n; i++){
        cin >> d[i] >> p[i];
    }
    for (int i = 0; i < q; i++){
        cin >> k[i];
    }
    d[n]=k[q-1]+1;
    int brojack=0;
    long long pojedeno=0;
    while(k[brojack]<d[0] && brojack<q)
    {
        cout << pojedeno << endl;
        brojack++;
    }
    for (int i = 0; i < n-1; i++)
    {
        if(d[i]+p[i]>d[i+1])
        {
            d[i+1]=d[i]+p[i];
        }
        while(k[brojack]<d[i+1] && brojack<q)
        {
            if(d[i]+p[i]>k[brojack])
            {
                pojedeno+=k[brojack]-d[i]+1;
                p[i]-=k[brojack]-d[i]+1;
                d[i]=k[brojack]+1;
            }
            else
            {
                pojedeno+=p[i];
                p[i]=0;
                d[i]=k[brojack]+1;
            }
            cout << pojedeno << endl;
            brojack++;
        }
        if(brojack<q)
        {
            pojedeno+=p[i];
        }
    }
    while(brojack<q)
    {
        if(d[n-1]+p[n-1]>k[brojack])
        {
            pojedeno+=k[brojack]-d[n-1]+1;
            p[n-1]-=k[brojack]-d[n-1]+1;
            d[n-1]=k[brojack]+1;
        }
        else
        {
            pojedeno+=p[n-1];
            p[n-1]=0;
            d[n-1]=k[brojack]+1;
        }
        cout << pojedeno << endl;
        brojack++;
    }
    return 0;
}