# Xi < X < Xi+1 となる X 地点に移動させるためのコスト # Σ{i=0~n}|Xi-X|*Wi # = Σ{i=0,k}(X-Xi)*Wi + Σ{i=k+1,n}(Xi-X)*Wi # = X*Σ{i=0~k}(Wi) - Σ{i=0~k}(XiWi) + Σ{i=k+1~n}(XiWi) - X*Σ{i=k+1~n}(Wi) # = 2*X*Σ{i=0~k}(Wi) - X*Σ{i=0~n}(Wi) - 2*Σ{i=0~k}(XiWi) + Σ{i=0~n}(XiWi) # A B C D import bisect N, Q = map(int, input().split()) bags = [] for _ in range(N): x, w = map(int, input().split()) bags.append((x, w)) bags.sort() X, W = [], [] for x, w in bags: X.append(x) W.append(w) A, C = [0] * (N + 1), [0] * (N + 1) B, D = 0, 0 for i in range(1, N + 1): A[i] = A[i - 1] + W[i - 1] C[i] = C[i - 1] + X[i - 1] * W[i - 1] B += W[i - 1] D += X[i - 1] * W[i - 1] for q in [int(s) for s in input().split()]: k = bisect.bisect_left(X, q) print(2 * q * A[k] - q * B - 2 * C[k] + D)