#include <stdio.h>

#define MAX_DAYS 100000

int main() {
    int N, Q;
    scanf("%d %d", &N, &Q);

    int dani[MAX_DAYS] = {0};
    int cumulative[MAX_DAYS] = {0};


    for (int i = 0; i < N; i++) {
        int di, pi;
        scanf("%d %d", &di, &pi);
        dani[di - 1] += pi;
    }

    cumulative[0] = dani[0];
    for (int i = 1; i < MAX_DAYS; i++) {
        cumulative[i] = cumulative[i - 1] + dani[i];
    }

    for (int j = 0; j < Q; j++) {
        int k;
        scanf("%d", &k);
        if (k > 0) {
            printf("%d\n", cumulative[k - 1]);
        } else {
            printf("0\n");
        }
    }

    return 0;
}