#P17100. [ICPC 2017 Qingdao R] The Squared Mosquito Coil

[ICPC 2017 Qingdao R] The Squared Mosquito Coil

Problem Description

Lusrica designs a mosquito coil in a board with n×nn \times n grids. The mosquito coil is a series of consecutive grids, each two neighboring grids of which share a common border. If two grids in the mosquito coil are not consecutive, they do not share any border, but they can share a common endpoint.

The mosquito coil Lusrica designed starts from the upper left corner of the board. It goes right to the last available grid. Alter the direction and go downward to the last available grid, and alter the direction again going left to the last available grid. To carry on after altering the direction and go upward to the last available grid. Then it goes right again and repeats the above turns.

It ends up in a grid such that the above process cannot be continued any more. Your mission now is to print the whole blueprint of Lusrica's mosquito coil.

Input Format

This problem has several test cases and the first line contains an integer tt (1t361 \le t \le 36) which is the number of test cases. For each case a line contains an integer nn (1n361 \le n \le 36) indicating the size of the board.

Output Format

For each case with input nn, output nn lines to describe the whole board. Each line contains nn characters. If a grid is a part of Lusrica's mosquito coil, the corresponding character is '#', or ' ' (a single blank) if not.

5
1
2
3
4
5
#
##
 #
###
  #
###
####
   #
#  #
####
#####
    #
### #
#   #
#####