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

    int N, Q;
    cin>>N>>Q;

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

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

    long pojedenaPlazma = 0;
    long index = 0;

    while(true){
        if(index >= Q)
            break;
        long temp = k[index];
        long plazma = 0;
        long dan = 0;
        for(long i = 0; i < N; i++){
            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;
        pojedenaPlazma = 0;
        index++;
    }

    return 0;
}