#include <iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    long long N, Q;
    cin>>N>>Q;

    long long d[N], p[N];
    for(long long i = 0; i<N; i++){
        cin>>d[i]>>p[i];
    }

    long long k[Q];
    for(long long j = 0; j<Q; j++){
        cin>>k[j];
    }

    long long index = 0;

    while(true){
        if(index >= Q)
            break;
        long long temp = k[index];
        long long plazma = 0;
        long long dan = 0;
        long long pojedenaPlazma = 0;
        
        for(long i = 0; i < N; i++){
            long long raspolozivaPlazma = 0;
            
            if(d[i] <= temp ){
                plazma += p[i];
                raspolozivaPlazma = (temp-d[i]) + 1;
            
                if(plazma > raspolozivaPlazma){
                    pojedenaPlazma += raspolozivaPlazma;
                    plazma -= raspolozivaPlazma;
                }else{
                    pojedenaPlazma += plazma;
                    plazma = 0; 
                }
            }
        }
        cout<<pojedenaPlazma<<endl;
        index++;
    }

    return 0;
}