#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int n, q;
    std::cin >> n >> q;
    std::vector<int> dl(1, 0);
    std::vector<int> pl(1, 0);

    for (int i = 0; i < n; ++i) {
        int d, p;
        std::cin >> d >> p;
        dl.push_back(d);
        pl.push_back(p);
    }

    for (int i = 0; i < q; ++i) {
        int j;
        std::cin >> j;
        std::vector<int> d1;

        for (int k = 0; k < dl.size(); ++k) {
            if (dl[k] <= j) {
                d1.push_back(dl[k]);
            }
        }

        int s = 0;
        for (size_t l = 1; l < d1.size(); ++l) {
            s += pl[l - 1];
        }

        if (s < *std::max_element(d1.begin(), d1.end())) {
            std::cout << s << std::endl;
        } else {
            std::cout << *std::max_element(d1.begin(), d1.end()) << std::endl;
        }
    }

    return 0;
}