#include <iostream>

using namespace std;

int closestDay = 0;

int srch(int days[], int n, int x){
    int l=0, r=n-1, sred, indL;

    if (x > days[n-1]){
        closestDay = days[n-1];
        return n-1;
    }

    while (l<=r){
        sred = (l+r)/2;

        indL = days[sred];

        if (indL<x && sred<n-1 && days[sred+1]>x){
            closestDay = indL;
            return sred;
        }
        else if (indL<x) l=sred+1;
        else if (indL>x && sred>0 && days[sred-1]<x){
            closestDay = days[sred-1];
            return sred-1;
        }
        else if (indL>x) r=sred-1;
        else{
            closestDay = indL;
            return sred;
        }
    }
    return -1;
}

void print(int lst[], int n){
    cout << endl;

    for (int i=0; i<n; i++){
        cout << lst[i] << " ";
    }

    cout << endl;
}

int main(){
    int n=1, q, d, p, currentSum = 0, cookiesLeft = 0, cookieSumDelta, day;

    cin >> n >> q;

    int preSum[n+1], cLft[n+1], dayMap[n], soList[q];

    preSum[0] = 0;
    cLft[0] = 0;

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

        dayMap[i] = d;

        (i>0)?cookieSumDelta = min(cookiesLeft, d - dayMap[i-1]): cookieSumDelta = min(cookiesLeft, d);

        currentSum += cookieSumDelta;
        cookiesLeft += p - cookieSumDelta;

        preSum[i+1] = currentSum;
        cLft[i+1] = cookiesLeft;
    }

    for (int i=0; i<q; i++){
        cin >> p;

        day = srch(dayMap, n, p) + 1;
        //print(dayMap, n);
        soList[i] = preSum[day] + min(p - closestDay+1, cLft[day]);
    }

    for (int i=0; i<q; i++){
        cout << soList[i] << endl;
    }
}