#include <stdio.h>
#include <stdlib.h>
#define maxdani 100000
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    long long dani[maxdani + 1] = {0};
    long long psuma[maxdani + 1] = {0};
    for (int i = 0; i < n; i++)
    {
        int d;
        long long p;
        scanf("%d %lld", &d, &p);
        dani[d] = dani[d] + p;
    }
    for (int i = 1; i <= maxdani; i++)
        psuma[i] = psuma[i - 1] + dani[i];
    for (int i = 0; i < q; i++)
    {
        long long k;
        scanf("%lld", &k);
        if (k > maxdani)
            printf("%lld\n", psuma[maxdani]);
        else
            printf("%lld\n", psuma[k]);
    }

    return 0;
}