#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;

    long long p[n];
    long long d[n];

    for (int i = 0; i < n; i++)
        cin >> d[i] >> p[i];

    long long s[n];
    s[0] = p[0];
    for (int i = 1; i < n; i++)
        s[i] = s[i-1]+p[i];

    vector<long long> rez;

    long long k[q];
    for (int i = 0; i < q; i++)
        cin >> k[i];

    long long r = 0;
    bool provera = false;
    if (q == 1){
        if (k[0] > d[0]){
            for (int i = 0; i < n; i++){
                if (d[i] > k[0]){
                    r = s[i]-k[0];
                    provera = true;
                    break;
                }
            }
            if (!provera)
                r = s[n-1]-k[0];

            rez.push_back(r);
        }

        else
            rez.push_back(0);
    }

    else {
        for (int i = 0; i < q; i++){
            if (k[i] < d[0])
                rez.push_back(0);

            else {
                if(s[i] < k[i])
                    rez.push_back(s[i]);

                else {
                    if (k[i] > d[i-1])
                        r = k[i]-d[0]+1;
                    else
                        r = rez[i-1]+abs(k[i]-d[i-1]);
                    rez.push_back(r);
                }
            }
        }
    }


    for (int i = 0; i < rez.size(); i++)
        cout << rez[i] << endl;

    return 0;
}