#include <iostream>
using namespace std;

unsigned long long int fin(unsigned long int N, unsigned long int p[], unsigned long long int d[], unsigned long long int q, unsigned long long int i, unsigned long long int r){
    if(d[i] <= q && i < N){
        if(p[i] < q - d[i] + 1){
            return fin(N, p, d, q, i + 1, r + p[i]);
        }else{
            return r + q- d[i] + 1;
        }
    }
    return r;
}

int main()
{
    unsigned long int N, Q;
    cin >> N >> Q;
    unsigned long int p[N];
    unsigned long long int d[N];
    unsigned long long int q[Q];
    for(int i = 0; i < N; i++){
        cin >> d[i] >> p[i];
    }
    for(int j = 0; j < Q; j++){
        cin >> q[j];
    }
    for(int j = 0; j < Q; j++){
        cout << fin(N, p, d, q[j], 0, 0) << endl;
    }
    

    return 0;
}