#!/usr/bin/env python3 import bisect import itertools class CumulativeSum(object): def __init__(self, sequence): self.cumulative_sum = [0] self.cumulative_sum.extend(itertools.accumulate(sequence)) def partial_sum(self, first, last): return self.cumulative_sum[last + 1] - self.cumulative_sum[first] def process_queries(xs, ws, ys): n = len(xs) w_cs = CumulativeSum(ws) xw_cs = CumulativeSum(x * w for x, w in zip(xs, ws)) for y in ys: pos = bisect.bisect(xs, y) left_sum = y * w_cs.partial_sum(0, pos - 1) - \ xw_cs.partial_sum(0, pos - 1) right_sum = xw_cs.partial_sum( pos, n - 1) - y * w_cs.partial_sum(pos, n - 1) all_sum = left_sum + right_sum yield all_sum def main(): n, q = (int(z) for z in input().split()) xs = [] ws = [] for _ in range(n): x, w = (int(z) for z in input().split()) xs.append(x) ws.append(w) ys = [int(z) for z in input().split()] for res in process_queries(xs, ws, ys): print(res) if __name__ == "__main__": main()