#include #define ALL(v) std::begin(v), std::end(v) #define ALLR(v) std::rbegin(v), std::rend(v) using ll = std::int64_t; using ull = std::uint64_t; using pii = std::pair; using tii = std::tuple; using pll = std::pair; using tll = std::tuple; template using vec = std::vector; template using vvec = vec>; template const T& var_min(const T &t) { return t; } template const T& var_max(const T &t) { return t; } template const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } template void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); } template void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); } template T make_v(T init) { return init; } template auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec(s, v); } template struct multi_dem_array { using type = std::array::type, Head>; }; template struct multi_dem_array { using type = std::array; }; template using mdarray = typename multi_dem_array::type; namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } namespace tree { template struct BIT { vec data; T id_ele; BIT(ll size, T id_ele) : id_ele(id_ele) { ll bsize = 1; while (bsize < size) bsize *= 2; data = vec(bsize + 1, id_ele); } T sum(ll pos) { T ret = id_ele; for (; 0 < pos; pos -= pos & -pos) ret += data[pos]; return ret; } T sum(ll l, ll r) { return sum(r) - sum(l); } void add(ll pos, T delta) { for (++pos; pos < data.size(); pos += pos & -pos) data[pos] += delta; } }; } namespace math { template constexpr T pow(const T &n, ll k) { T ret = n.mul_id_ele(); T cur = n; while (k) { if (k & 1) ret *= cur; cur *= cur; k /= 2; } return ret; } } namespace math { template struct Modint { constexpr Modint(ll x) : x((Mod + x % Mod) % Mod) { } constexpr Modint() : Modint(0) { } constexpr Modint add_id_ele() const { return Modint(0); } constexpr Modint mul_id_ele() const { return Modint(1); } constexpr ll& value() { return x; } constexpr ll value() const { return x; } constexpr Modint& operator +=(const Modint &oth) { x += oth.value(); if (Mod <= x) x -= Mod; return *this; } constexpr Modint& operator -=(const Modint &oth) { x += Mod - oth.value(); if (Mod <= x) x -= Mod; return *this; } constexpr Modint& operator *=(const Modint &oth) { x *= oth.value(); x %= Mod; return *this; } constexpr Modint& operator /=(const Modint &oth) { x *= oth.inv(); x %= Mod; return *this; } constexpr Modint operator +(const Modint &oth) const { return Modint(x) += oth; } constexpr Modint operator -(const Modint &oth) const { return Modint(x) -= oth; } constexpr Modint operator *(const Modint &oth) const { return Modint(x) *= oth; } constexpr Modint operator /(const Modint &oth) const { return Modint(x) /= oth; } constexpr Modint operator -() const { return Modint((x != 0) * (Mod - x)); } template constexpr typename std::enable_if::value, const Modint&>::type operator =(T t) { (*this) = Modint(std::forward(t)); return *this; } constexpr Modint inv() const { return ::math::pow(*this, Mod - 2); } constexpr ll mod() const { return Mod; } private: ll x; }; } int main() { ll n, q; std::cin >> n >> q; vec xw(n); vec xv(q); for (auto &&e : xw) { ll x, w; std::cin >> x >> w; e = pll(x, w); } for (ll &e : xv) std::cin >> e; std::sort(ALL(xw)); std::sort(ALL(xv)); vec ans1(q), ans2(q); std::queue qf, qb; for (ll i = 0; i < n; i++) { qf.push(xw[i]); qb.push(xw[n - 1 - i]); } { ll sum = 0 , pre = 0; for (ll i = 0; i < q; i++) { ll x = xv[i]; if (i) ans1[i] += ans1[i - 1]; ans1[i] += (x - pre) * sum; pre = x; while (qf.size()) { ll xf, w; std::tie(xf, w) = qf.front(); if (x < xf) break; qf.pop(); sum += w; ans1[i] += (x - xf) * w; } } } { ll sum = 0, pre = 0; for (ll i = q - 1; 0 <= i; i--) { ll x = xv[i]; if (i + 1 < q) ans2[i] += ans2[i + 1]; ans2[i] += (pre - x) * sum; pre = x; while (qb.size()) { ll xb, w; std::tie(xb, w) = qb.front(); if (xb < x) break; qb.pop(); sum += w; ans2[i] += (xb - x) * w; } } } for (ll i = 0; i < q; i++) std::cout << ans1[i] + ans2[i] << '\n'; return 0; }