#include <bits/stdc++.h>
using namespace std;

int main() {
    long long int n, q, i, j, rez, brp, c;

    scanf("%lld %lld", &n, &q);
    
    long long d[n], p[n], b[q];
    
    for (i = 0; i < n; i++) {
        scanf("%lld %lld", &d[i], &p[i]);
    }
    
    for (j = 0; j < q; j++) {
        scanf("%lld", &b[j]);
    }
    
    long long sum[n];
    sum[0] = p[0];
    for (i = 1; i < n; i++) {
        sum[i] = sum[i-1] + p[i];
    }

    for (j = 0; j < q; j++) {
        rez = 0;
        brp = 0;
        
        for (c = 1, i = 0; c <= b[j]; c++) {
            if (i < n && d[i] == c) {
                brp += p[i];
                i++;
            }

            if (brp > 0) {
                rez++;
                brp--;
            }
        }
        
        printf("%lld\n", rez);
    }

    return 0;
}