#include <stdio.h>

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

    int days[N], packs[N];
    for (i = 0; i < N; i++) {
        scanf("%d %d", &days[i], &packs[i]);
    }

    int queries[Q];
    for (i = 0; i < Q; i++) {
        scanf("%d", &queries[i]);
    }

    for (int j = 0; j < Q; j++) {
        int stop_day = queries[j];
        int pakovanja = 0;
        int eaten = 0;
        int dan = 0;

        while(pakovanja > 0 || i<stop_day)
        {
            if(days[dan] == i)
            {
                pakovanja += packs[dan];
                dan++;
            }

            if(pakovanja > 0 && i<stop_day)
            {
                pakovanja--;
                eaten++;
            }
            i++;
        }
        



        printf("%d\n", eaten);
    }

    return 0;
}