#include <bits/stdc++.h>

using namespace std;

struct Dogadjaj {
    int dan;
    int kolicina;
};

bool porediDogadjaje(const Dogadjaj& a, const Dogadjaj& b) {
    return a.dan < b.dan;
}

int main() {
    int N, Q;
    cin >> N >> Q;

    vector<Dogadjaj> dogadjaji(N);
    for (int i = 0; i < N; ++i) {
        cin >> dogadjaji[i].dan >> dogadjaji[i].kolicina;
    }

    sort(dogadjaji.begin(), dogadjaji.end(), porediDogadjaje);

    vector<int> ukupno(N);
    ukupno[0] = dogadjaji[0].kolicina;
    for (int i = 1; i < N; ++i) {
        ukupno[i] = ukupno[i - 1] + dogadjaji[i].kolicina;
    }

    for (int q = 0; q < Q; ++q) {
        int dan;
        cin >> dan;

        vector<Dogadjaj>::iterator it = upper_bound(dogadjaji.begin(), dogadjaji.end(), Dogadjaj{dan, 0}, porediDogadjaje);
        int indeks = distance(dogadjaji.begin(), it) - 1;

        cout << ukupno[indeks] << endl;
    }

    return 0;
}