#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;

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

    vector<long long> upiti(q);
    for (int i = 0; i < q; i++) cin >> upiti[i];
    for (int j = 0; j < q; j++)
    {
        long long do_kog = d[0], ukupno = 0, ostatak = 0;
        for (int i = 0; i < n && do_kog <= upiti[j]; i++)
        {
            do_kog = max(do_kog, d[i]);
            ukupno += min(upiti[j] - do_kog + 1, p[i]);
            ostatak += p[i] - min(upiti[j] - do_kog + 1, p[i]);
            do_kog += p[i];
            if (ostatak) break;
        }
        cout << ukupno << endl;
    }
    

}