#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; struct ST { int t; ll x, w; }; bool operator<(const ST& a ,const ST& b){ return a.x < b.x; } int main(){ int N, Q; cin >> N >> Q; vector v; rep(i,N){ ST st; st.t = -1; cin >> st.x >> st.w; v.push_back(st); } rep(i,Q){ ST st; st.t = i; st.w = 0; cin >> st.x; v.push_back(st); } sort(ALLOF(v)); vector ret(Q, 0); { ll base = 0; ll prev_sum = 0; ll prev_x = v[0].x; rep(i,v.size()){ if(v[i].t >= 0){ ret[v[i].t] += prev_sum + (v[i].x - prev_x) * base; } prev_sum += (v[i].x - prev_x) * base; prev_x = v[i].x; base += v[i].w; } } { ll base = 0; ll prev_sum = 0; ll prev_x = v[v.size()-1].x; for(int i=v.size()-1; i>=0; i--){ if(v[i].t >= 0){ ret[v[i].t] += prev_sum + (prev_x - v[i].x) * base; } prev_sum += (prev_x - v[i].x) * base; prev_x = v[i].x; base += v[i].w; } } rep(i,ret.size()){ cout << ret[i] << endl; } return 0; }