#include <stdio.h>

int main() {
    unsigned int N, Q;
    scanf("%u %u", &N, &Q);
    
    unsigned int d[100000], p[100000];
    
    for (unsigned int i = 0; i < N; i++) {
        scanf("%u %u", &d[i], &p[i]);
    }
    
    unsigned int k[300000];
    for (unsigned int i = 0; i < Q; i++) {
        scanf("%u", &k[i]);
    }

    unsigned int odgovori[300000];
    
    unsigned int j = 0;
    unsigned int brojpaketa = 0;
    
    for (unsigned int i = 0; i < Q; i++) {
        unsigned int trenutnik = k[i];
        
        while (j < N && d[j] <= trenutnik) {
            brojpaketa += p[j];
            j++;
        }
        
        odgovori[i] = brojpaketa;
    }
    
    for (unsigned int i = 0; i < Q; i++) {
        printf("%u\n", odgovori[i]);
    }
    
    return 0;
}