import sys input = sys.stdin.readline def main(): n, q = map(int, input().split()) L = [] xs = [] for i in range(n): x, w = map(int, input().split()) L.append([x, w]) xs.append(x) X = list(map(int, input().split())) L.sort() xs.sort() Wl = [0]*n Wr = [0]*n wsl = [0]*n wsr = [0]*n for i in range(n): if i == 0: wsl[i] = L[i][1] else: wsl[i] = wsl[i-1] + L[i][1] Wl[i] = wsl[i-1]*(xs[i]-xs[i-1]) + Wl[i-1] for i in reversed(range(n)): if i == n-1: wsr[i] = L[i][1] else: j = n-1-i wsr[i] = wsr[i+1] + L[i][1] Wr[i] = wsr[i+1]*(xs[i+1]-xs[i]) + Wr[i+1] #print(Wl) #print(Wr) import bisect anss = [] for x in X: if x < min(xs): ans = wsr[0]*(xs[0]-x)+Wr[0] elif x >= max(xs): ans = wsl[-1]*(x-xs[-1])+Wl[-1] else: id = bisect.bisect_right(xs, x) ans = wsl[id-1]*(x-xs[id-1])+Wl[id-1]+ wsr[id]*(xs[id]-x)+Wr[id] anss.append(ans) print(*anss, sep='\n') if __name__ == '__main__': main()