Cell Automaton

아직 제출이 없습니다시간 제한6초메모리 제한1024 MB

문제

We have a sufficiently large 22-dimensional grid of cells. The grid is paved with square cells from the top to the bottom and from the left to the right.

There is a cell, which is the origin of the coordinates. Let (x,y)(x, y) denote the cell one arrives at when one moves from the origin to the right direction for the distance of xx cells and to the upward direction for the distance of yy cells. Here, the left direction for the distance of aa cells means the right direction for the distance of a-a cells. Similarly, the downward direction for the distance of aa cells means the upward direction for the distance of a-a cells.

At time 00, the cells (X_1,Y_1),(X_2,Y_2),,(X_N,Y_N)(X\_1, Y\_1), (X\_2, Y\_2), \dots , (X\_N, Y\_N) are black, and all of the other cells are white.

For t=0,1,2,t = 0, 1, 2, \dots, the colors of the cells at time t+1t + 1 are determined by the colors of the cells at time tt in the following way.

  • If a cell is black at time tt, then the cell becomes gray at time t+1t + 1.
  • If a cell is gray at time tt, then the cell becomes white at time t+1t + 1.
  • A cell which is white at time tt becomes black at time t+1t + 1 if at least one of the 44 adjacent cells (i.e. the 44 cells which share the edges) is black at time tt. Otherwise, it remains white at time t+1t + 1.

You have QQ queries. For the jj-th (1jQ1 ≤ j ≤ Q) query, you should answer the number of black cells at time T_jT\_j.

Write a program which, given the information of the colors of the cells at time 0 and queries, answers the queries.

입력

Read the following data from the standard input.

NN QQ

X_1X\_1 Y_1Y\_1

X_2X\_2 Y_2Y\_2

\vdots

X_NX\_N Y_NY\_N

T_1T\_1

T_2T\_2

\vdots

T_QT\_Q

출력

Write QQ lines to the standard output. The jj-th line should contain the number of black cells at time T_jT\_j.

제한

  • 1N100,0001 ≤ N ≤ 100\\,000.
  • 1Q500,0001 ≤ Q ≤ 500\\,000.
  • X_i109|X\_i | ≤ 10^9 (1iN1 ≤ i ≤ N).
  • Y_i109|Y\_i | ≤ 10^9 (1iN1 ≤ i ≤ N).
  • (X_i,Y_i)(X_j,Y_j)(X\_i , Y\_i) \ne (X\_j , Y\_j) (1i<jN1 ≤ i < j ≤ N).
  • 0T_j1090 ≤ T\_j ≤ 10^9 (1jQ1 ≤ j ≤ Q).
  • T_j<T_j+1T\_j < T\_{j+1} (1jQ11 ≤ j ≤ Q - 1).
  • Given values are all integers.