#include <iostream>
using namespace std;

#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,q;
    cin >> n >> q;
    ll x[n],y[n];
    for(ll i = 0; i < n; i++) cin >> x[i] >> y[i];
    for(ll i = 0; i < q; i++) {
        ll g,v=0,r=0,j=1;
        cin >> g;
        while(j!=n) {
            if(x[j] < g) {
                if(y[j-1] > (x[j]-x[j-1])) {
                    r+= (x[j]-x[j-1]);
                    v+= y[j-1] - (x[j]-x[j-1]);
                }
                else {
                    r+= y[j-1] + min(v,(x[j]-x[j-1])-y[j-1]);
                    v-=min(v,(x[j]-x[j-1])-y[j-1]);
                }
            }
            else break;
            j++;
        }
        j--;
        if(g > x[0])v+= y[j];
        if((max((ll)0,g-x[j] )< v))r++;
        r+=max((ll)0,min((g-x[j]),v));
        cout << r << "\n";
    }
}