#include <bits/stdc++.h>

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);
    vector <int> p(n);
    vector <int> k(q);
    vector <long long> r(q, 0);
    for (int i = 0; i < n; i++){
        cin >> d[i] >> p[i];
    }
    for (int i = 0; i < q; i++){
        cin >> k[i];
    }
    for (int i = 0; i < q; i++){
        for (int j = 0; j < n; j++){
            if (d[j] <= k[i]){
                if (p[j] > k[i]-d[j]+1){
                    r[i] += k[i]-d[j]+1;
                    break;
                }
                else{
                    r[i] += p[j];
                }
            }
        }
    }
    for (int i = 0; i < q; i++){
        cout << r[i] << '\n';
    }
    return 0;
}