We define a series as follows:
We define a Hackonacci Matrix to be an matrix where the rows and columns are indexed from to , and the top-left cell is . Each cell must contains either the character X
or the character Y
. If is even, it's X
; otherwise, it's Y
.
Next, we want to perform queries where each query consists of an integer, . Each is a multiple of degrees and describes the angle by which you must rotate the matrix in the clockwise direction. For each , we want to count the number of cells that are different after the rotation. For example, the diagram below depicts the rotation of a Hackonacci Matrix when :
As you can see, there are two cells whose values change after the rotation. Note that we filled each initial cell using the Hackonacci formula given above:
- :
Because this is an odd number, we mark this cell with aY
. - :
Because this is an even number, we mark this cell with anX
. - :
Because this is an even number, we mark this cell with anX
. - :
Because this is an even number, we mark this cell with anX
.
Given the value of and queries, construct a Hackonacci Matrix and answer the queries. For each query , print an integer on a new line denoting the number of cells whose values differ from the initial Hackonacci Matrix when it's rotated by degrees in the clockwise direction.
Input Format
The first line contains two space-separated integers describing the respective values of and .
Each line of the subsequent lines contains an integer denoting .
Constraints
- It is guaranteed that each is multiple of degrees.
Output Format
For each , print a single integer on a new line denoting the number of different cells that differ between the initial matrix and the matrix rotated by degrees.
Sample Input 0
4 3
90
180
270
Sample Output 0
10
6
10
Explanation 0
Because , we must build a Hackonacci matrix and then perform queries, shown below. The following diagrams depict each query rotation, and cells whose values changed after performing a rotation are highlighted in orange:
- When we perform a rotation on the matrix, there are cells whose values change:
Thus, we print on a new line. - When we perform a rotation on the matrix, there are cells whose values change:
Thus, we print on a new line. - When we perform a rotation on the matrix, there are cells whose values change:
Thus, we print on a new line.