#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, q;
    cin >> n >> q;

    vector<long long> d(n), p(n), k(q);

    for(int i = 0; i < n; i++){
        cin >> d[i] >> p[i];
    }

    for(int i = 0; i < q; i++){
        cin >> k[i];
    }

    int a = 0, b = 0;
    long long c = 0, z = 0; //koliko je pojela zalihe i koji
    while(b < q){
        if(a < n && d[a] <= k[b]){
            if(a != 0){
                c += min(d[a]-d[a-1], z);
                z -= min(d[a]-d[a-1], z);
            }
            z += p[a];

            a++;
        }
        else{
            if(a != 0) cout << c + min(k[b]-d[a-1]+1, z) << endl;
            else cout << 0 << endl;

            b++;
        }
    }
}