//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} const int N =1e5+10; //head int n, q; P x[N]; //x, w ll sum1[N], sum2[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q; rep(i, n) cin >> x[i]; sort(x, x+n); rep(i, n) { sum1[i+1] = sum1[i] + x[i].second; sum2[i+1] = sum2[i] + ll(x[i].first)*x[i].second; } while(q--) { ll X; cin >> X; int num = lower_bound(x, x+n, P(X, 0)) - x; ll res = 0; res += sum1[num] * X; res -= sum2[num]; res -= (sum1[n] - sum1[num]) * X; res += sum2[n] - sum2[num]; cout << res << '\n'; } }