Ada King Problem Code: ADAKING

Read problem statements in Hindi, Bengali, Mandarin Chinese, Russian, and Vietnamese as well.

Chef Ada is training her calculation skills. She wants to place a king and some obstacles on a chessboard in such a way that the number of distinct cells the king can reach is exactly .

Recall that a chessboard has  rows (numbered  through ) and  columns (numbered  through ); let's denote a cell in row  and column  by .

In one move, a king can move to any adjacent cell which shares a side or corner with its current cell and does not contain an obstacle. More formally, a king in a cell  can move to any cell  if  is a valid cell of the chessboard which does not contain an obstacle and . 

A cell  can be reached by a king if, after an arbitrary number of moves (including zero), the king is in the cell .

Help Ada find any valid configuration of the board such that the king can reach exactly  distinct cells. It is guaranteed that such a configuration always exists. If there are multiple solutions, you may find any one.

Input

  • The first line of the input contains a single integer  denoting the number of test cases. The description of  test cases follows.
  • The first and only line of each test case contains a single integer .

Output

For each test case, print  lines describing a chessboard, each containing characters. For each valid  and , the -th character on the -th line should be one of the following:

  • 'O' if the cell  initially contains the king; there should be exactly one such cell
  • 'X' if the cell  contains an obstacle
  • '.' if the cell  is empty

Constraints

Subtasks

Subtask #1 (10 points): 

Subtask #2 (90 points): original constraints

Example Input

4
1
5
9
64

Example Output

........
........
........
.XXX....
.XOX....
.XXX....
........
........

........
........
........
........
........
XXX.....
..XX....
O..X....

........
.XXXXXXX
.X.O...X
.X...XXX
.XXX.X..
...XXX..
........
........

........
........
........
...O....
........
........
........
........

Explanation

The descriptions of the chessboard for each test case are separated by blank lines for clarity. Note that these lines should not appear on the output of your submission.

Example case 1: The king is surrounded by obstacles, so it cannot move ― the only cell it can reach is its initial cell.

Example case 4: The king can visit all cells of the board.

Comments

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius