#include using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::cerr; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { int n, q; scanf("%d%d", &n, &q); std::vector a(n), b(n), c(q); for(int i = 0; i < n; i++) scanf("%lld%lld", &a[i], &b[i]); for(int i = 0; i < q; i++) scanf("%lld", &c[i]); std::vector> A, B; for(int i = 0; i < n; i++) A.push_back({a[i], i}); for(int i = 0; i < q; i++) B.push_back({c[i], i}); sort(begin(A), end(A)); sort(begin(B), end(B)); int cnt = 0; i64 now = 0, L = 0, R = std::accumulate(begin(b), end(b), 0LL), last = 0; for(int i = 0; i < n; i++) now += a[i] * b[i]; std::vector ans(q); for(int i = 0; i < B.size(); i++) { int x = B[i].first; while(cnt < A.size() and A[cnt].first <= x) { int id = A[cnt++].second; i64 len = a[id] - last; now += len * L; now -= len * R; last = a[id]; L += b[id]; R -= b[id]; } i64 len = x - last; now += len * L; now -= len * R; last = x; ans[B[i].second] = now; } for(auto v: ans) printf("%lld\n", v); return 0; }