#include using namespace std; long long int res[100005]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, q, x, w, t; vector , int>> v; cin >> n >> q; for (int i = 0; i < n; i++) { cin >> x >> w; v.push_back(make_pair(make_pair(x, 1), w)); } for (int i = 0; i < q; i++) { cin >> t; v.push_back(make_pair(make_pair(t, 0), i)); } sort(v.begin(), v.end()); long long int sum = 0; long long int X = v[0].first.first; long long int val = 0; for (int i = 0; i < v.size(); i++) { long long int x = v[i].first.first; int sel = v[i].first.second; val += ((x - X) * sum); X = x; if (sel == 0) { int idx = v[i].second; res[idx] += val; } else { sum += v[i].second; } v[i].first.second = 1 - v[i].first.second; } sort(v.rbegin(), v.rend()); sum = 0; X = v[0].first.first; val = 0; for (int i = 0; i < v.size(); i++) { long long int x = v[i].first.first; int sel = v[i].first.second; val += ((X - x) * sum); X = x; if (sel == 1) { int idx = v[i].second; res[idx] += val; } else { sum += v[i].second; } v[i].first.second = 1 - v[i].first.second; } for (int i = 0; i < q; i++) { cout << res[i] << '\n'; } return 0; }