We have a sufficiently large 2-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) denote the cell one arrives at when one moves from the origin to the right direction for the distance of x cells and to the upward direction for the distance of y cells. Here, the left direction for the distance of a cells means the right direction for the distance of −a cells. Similarly, the downward direction for the distance of a cells means the upward direction for the distance of −a cells.
At time 0, the cells (X_1,Y_1),(X_2,Y_2),…,(X_N,Y_N) are black, and all of the other cells are white.
For t=0,1,2,…, the colors of the cells at time t+1 are determined by the colors of the cells at time t in the following way.
You have Q queries. For the j-th (1≤j≤Q) query, you should answer the number of black cells at time T_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.
N Q
X_1 Y_1
X_2 Y_2
⋮
X_N Y_N
T_1
T_2
⋮
T_Q
Write Q lines to the standard output. The j-th line should contain the number of black cells at time T_j.