import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int q = Integer.parseInt(sa[1]); Obj[] arr = new Obj[n]; for (int i = 0; i < n; i++) { sa = br.readLine().split(" "); Obj o = new Obj(); o.x = Integer.parseInt(sa[0]); o.w = Integer.parseInt(sa[1]); arr[i] = o; } sa = br.readLine().split(" "); Query[] qu = new Query[q]; for (int i = 0; i < q; i++) { Query o = new Query(); o.i = i; o.x = Integer.parseInt(sa[i]); qu[i] = o; } br.close(); Arrays.parallelSort(arr, (o1, o2) -> o1.x - o2.x); Arrays.parallelSort(qu, (o1, o2) -> o1.x - o2.x); long right = 0; for (int i = 0; i < n; i++) { right += arr[i].w; } int pre = 0; int idx = 0; long left = 0; for (int i = 0; i < q; i++) { long val = left * (qu[i].x - pre); if (i > 0) { val += qu[i - 1].ans; } while (idx < n) { Obj o = arr[idx]; if (o.x <= qu[i].x) { val += (qu[i].x - o.x) * o.w; if (i > 0) { val -= (o.x - qu[i - 1].x) * o.w; } left += o.w; right -= o.w; idx++; } else { break; } } if (i == 0) { for (int j = idx; j < n; j++) { val += (arr[j].x - qu[i].x) * arr[j].w; } } else { val -= right * (qu[i].x - pre); } qu[i].ans = val; pre = qu[i].x; } Arrays.parallelSort(qu, (o1, o2) -> o1.i - o2.i); PrintWriter pw = new PrintWriter(System.out); for (Query o : qu) { pw.println(o.ans); } pw.flush(); } static class Obj { int x, w; } static class Query { int i, x; long ans; } }