#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n, q;
    cin >> n >> q;
 
    long long dan[400000], plazma[400000], zbir[400000];
 
    for (int i = 0; i < n; i++) {
        cin >> dan[i] >> plazma[i];
    }
 
    zbir[0] = plazma[0];
    for (int i = 1; i < n; i++) {
        zbir[i] = zbir[i - 1] + plazma[i];
    }
 
    while (q--) {
        long long upit;
        cin >> upit;
 
        int a = -1;
        int levo = 0, desno = n - 1;
 
        while (levo <= desno) {
            int b = levo + (desno - levo) / 2;
            if (dan[b] <= upit) {
                a = b; 
                levo = b + 1; 
            } else {
                desno = b - 1; 
            }
        }
 
        if (a < 0) {
            cout << 0 << endl; 
        } else if (a >= 0) {
            long long pojedeno = (a == 0) ? min(zbir[a], upit + 1 - dan[a]) : min(zbir[a], upit + 1 + zbir[a - 1] - dan[a]);
            cout << pojedeno << endl;
            }
        }
    }