#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    int N, Q, i, j = 0, br = 0;
    vector<long long int> d;
    vector<long long int> p;
    vector<long long int> r;
    cin >> N >> Q;
    d.reserve(N);
    p.reserve(N);
    r.reserve(Q);
    long long int x, s = 0, y;
    for(i=0; i<N; i++){
        cin >> x >> y;
        d.push_back(x);
        p.push_back(y);
    }
    for(i = 0; i < Q; i++){
        cin >> x;
        for(j = br; j < N; j++){
            if(x > d[j]){
                if(j == N-1){
                    y = x - d[j] + 1;
                    if(p[j] > y){
                        s+= y;
                        d[j] = x+1;
                        p[j] -= y;
                    }
                    else{
                        s += p[j];
                        p[j] = 0;
                        d[j] = x+1;
                    }
                    r.push_back(s);
                    break;
                }
                else if(x > d[j+1]){
                    y = d[j+1] - d[j];
                    if(p[j] > y){
                        s += y;
                        p[j+1] += p[j] - y;
                    }
                    else{
                        s += p[j];
                    }
                    br++;
                }
                else{
                    y = x - d[j] + 1;
                    if(p[j] > y){
                        s+= y;
                        if(d[j+1] == x+1){
                            p[j+1] += p[j]-y;
                            br++;
                        }
                        else{
                            d[j] = x+1;
                            p[j] -= y;
                        }
                    }
                    else{
                        s += p[j];
                        br++;
                    }
                    r.push_back(s);
                    break;
                }
            }
            else{
                r.push_back(s);
                break;
            }
        }
    }
    for(i = 0; i < r.size(); i++){
        cout << r[i] << endl;
    }
}