#include<bits/stdc++.h>
using namespace std;
int n, q, br = 1;
long long p[300005], d[300005], k[300005], sum;
int main(){
    cin >> n >> q;
    for(int i = 1; i <= n; i++){
        cin >> d[i] >> p[i];
    }
    for(int i = 1; i <= q; i++){
        cin >> k[i];
    }
    for(int i = 1; i <= q; i++){
        for(int j = 1; j<=k[i]; j++){
            if(d[br] <= k[i] and p[br] <= k[i]){
                sum+=p[br];
                j+=p[br];
            }
            else if(d[br] <= k[i] and p[br] > k[i]){
                sum+=(k[i]-j);
                j+=(k[i]-j);
            }
            br++;
        }
        cout << sum << endl;
        sum = 0;
    }
    return 0;
}