#include #include #include #include #include #include #include using namespace std; #define rep(i,x) for(ll i = 0; i < (ll)(x); i++) #define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--) #define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++) #define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--) #define debug(x) cerr << #x << ": " << (x) << "\n"; #define all(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair P; typedef pair Pll; typedef vector vl; typedef vector> vvl; typedef vector>> vvvl; const ll INF = numeric_limits::max()/4; const int n_max = 1e5+10; int main(){ ll n,q; cin >> n >> q; vector a(n),b(n); rep(i,n)cin >> a[i] >> b[i]; vector sum_ab(n+1), sum_b(n+1); rep(i,n){ sum_ab[i+1] = sum_ab[i] + a[i] * b[i]; sum_b[i+1] = sum_b[i] + b[i]; } vector x(q); rep(i,q) cin >> x[i]; rep(i,q){ ll id = lower_bound(all(a), x[i]) - a.begin(); // debug(id); ll ans = 0; ans -= sum_ab[id] - sum_ab[0]; ans += sum_ab[n] - sum_ab[id]; ans += x[i] * (sum_b[id] - sum_b[0]); ans -= x[i] * (sum_b[n] - sum_b[id]); cout << ans << "\n"; } }