#include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; vector x(n), w(n); for (int i = 0; i < n; i++) { cin >> x[i] >> w[i]; } vector s0(n + 1), w0(n + 1); for (int i = 0; i < n; i++) { s0[i + 1] = s0[i] + (ll)x[i] * w[i]; w0[i + 1] = w0[i] + w[i]; } for (int _ = 0; _ < q; _++) { int X; cin >> X; int k = lower_bound(x.begin(), x.end(), X) - x.begin(); ll r = -s0[k] + X * w0[k] + (s0[n] - s0[k]) - X * (w0[n] - w0[k]); cout << r << '\n'; } return 0; }