#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{   
    int N, Q;
    scanf("%d %d", &N, &Q);
    int d[100000], p[100000], k[100000], i, j, zdan=0,dan,plazma[100000],pojela[100000];
    printf("\n");
    for (i = 0; i < N; i++) 
        scanf("%d %d", &d[i], &p[i]);
    printf("\n");
    for (i = 0; i < Q; i++) 
    {
        scanf("%d", &k[i]);
        if (k[i] > zdan) 
            zdan = k[i];
    }
 
    for (i = 0; i < N; i++) 
    {
        plazma[d[i]] =plazma[d[i]] + p[i];
    }

    for (dan = 1; dan <= zdan; dan++) 
    {
        plazma[dan] = plazma[dan] + plazma[dan - 1]; 
        if (plazma[dan] > 0) 
        {
            pojela[dan] = pojela[dan - 1] + 1;
            plazma[dan]--;
        } else 
        {
            pojela[dan] = pojela[dan - 1]; 
        }
    }
    printf("\n");
    for (i = 0; i < Q; i++) 
    {
        printf("%d\n", pojela[k[i]]);
    }

    return 0;
}