#include<bits/stdc++.h>
using namespace std;
int n, q;
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[j] <= k[i] and p[j] <= k[i]){
                sum+=p[j];
                j+=p[j];
            }
            else if(d[j] <= k[i] and p[j] > k[i]){
                sum+=(k[i]-i);
                j+=(k[i]-i);
            }
        }
        cout << sum << endl;
        sum = 0;
    }
    return 0;
}