#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]; } sort(y.begin(), y.end()); lint pos = 1; lint posx = 0; for (int i = 0; i < q; ++i) { while (posx < n && xw[posx].first < y[i]) { cost += weight * (xw[posx].first - pos); weight += xw[posx].second * 2; pos = xw[posx].first; posx++; } cout << cost + weight * (y[i] - pos) << "\n"; } return 0; }