import bisect n,q = map(int,input().split()) xw = [[int(i) for i in input().split()] for j in range(n)] x = [int(i) for i in input().split()] xx = [] for i in range(q): xx.append([x[i],i]) xx.sort() x.sort() xw.sort() pos = [] wei = [] for i in range(n): pos.append(xw[i][0]) wei.append(xw[i][1]) rw = [0]*(n+1) for i in range(n): rw[i+1] = rw[i]+wei[i] ali = [0]*q ans = 0 for i in range(n): ans += abs(x[0]-pos[i])*wei[i] ali[xx[0][1]] = ans print(ans) for i in range(q-1): bidx = bisect.bisect_right(pos,x[i]) aidx = bisect.bisect_left(pos,x[i+1]) #print(bidx,aidx,rw) ans += (x[i+1]-x[i])*(rw[bidx]-rw[0]) ans -= (x[i+1]-x[i])*(rw[n]-rw[aidx]) for j in range(bidx,aidx): ans -= abs(x[i]-pos[j])*wei[j] ans += abs(x[i+1]-pos[j])*wei[j] #print(ans) ali[xx[i+1][1]] = ans print(*ali,sep="\n")