#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

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

    vector<long> dan(n);
    vector<long> plazme(n);
    for (int i = 0; i < n; i++) {
        cin >> dan[i] >> plazme[i];
    }

    for (long i = 0; i < q; i++) {
        long k;
        cin >> k;
        long skobo = 0;
        for (long j = 0; j < n; j++) {
            if (dan[j] + plazme[j] <= k) 
            {
                skobo += plazme[j];
            } 
            else if (dan[j] <= k) 
            {
                if (plazme[j] < k - dan[j] + 1)
                    skobo += plazme[j];
                else
                    skobo += k - dan[j] + 1;
            }
            else 
            {
                break;
            }
        }
        cout << skobo << endl;
    }

    return 0;
}