#include using namespace std; using lint = long long; const lint inf = 1LL << 60; const lint mod = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); lint n, q; cin >> n >> q; vector> xw(n); lint weight = 0; lint cost = 0; for (int i = 0; i < n; ++i) { cin >> xw[i].first >> xw[i].second; weight -= xw[i].second; cost += abs(xw[i].first - 1) * xw[i].second; } sort(xw.begin(), xw.end()); vector> y(q); for (int i = 0; i < q; ++i) { cin >> y[i].first; y[i].second = i; } sort(y.begin(), y.end()); vector ret(q); lint pos = 1; lint posx = 0; for (int i = 0; i < q; ++i) { while (posx < n && xw[posx].first < y[i].first) { cost += weight * (xw[posx].first - pos); weight += xw[posx].second * 2; pos = xw[posx].first; posx++; } ret[y[i].second] = cost + weight * (y[i].first - pos); } for (auto &r : ret) { cout << r << "\n"; } return 0; }