#include <iostream>
using namespace std;

bool in(int x, int y, int n) {
	return 0 <= x && x < n && 0 <= y && y < n;
}

int main() {
	int d;
	cin >> d;
	for(int t = 0; t < d; t++) {
		char str[128][128];
		int n;
		cin >> n;

		for(int i = 0; i < 128; i++)
			for(int j = 0; j < 128; j++)
				str[i][j] = ' ';

		int x = 0, y = n - 1;
		int dir = 0;
		int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
		bool flag = false;
		while(1) {
			str[y][x] = '#';
			/*
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++)
					cout << ((i == y && j == x) ? '*' : str[i][j]);
				cout << endl;
			}
			cout << (dir == 0 ? "up" : dir == 1 ? "forward" : dir == 2 ? "down" : "back") << endl;
			cout << endl;
			*/

			int nx, ny;
			bool turn_flag = false;
			nx = x + dx[dir]; ny = y + dy[dir];

			if(in(nx+dx[dir], ny+dx[dir], n))
				turn_flag |= str[ny+dx[dir]][nx+dx[dir]] == '#';
			if(in(nx+dx[dir], ny        , n))
				turn_flag |= str[ny        ][nx+dx[dir]] == '#';
			if(in(nx+dx[dir], ny-dx[dir], n))
				turn_flag |= str[ny-dx[dir]][nx+dx[dir]] == '#';

			if(in(nx, ny+dx[dir], n))
				turn_flag |= str[ny+dx[dir]][nx] == '#';
			if(in(nx, ny        , n))
				turn_flag |= str[ny        ][nx] == '#';
			if(in(nx, ny-dx[dir], n))
				turn_flag |= str[ny-dx[dir]][nx] == '#';

			if(in(nx+dy[dir], ny+dy[dir], n))
				turn_flag |= str[ny+dy[dir]][nx+dy[dir]] == '#';
			if(in(nx        , ny+dy[dir], n))
				turn_flag |= str[ny+dy[dir]][nx        ] == '#';
			if(in(nx-dy[dir], ny+dy[dir], n))
				turn_flag |= str[ny+dy[dir]][nx-dy[dir]] == '#';

			if(in(nx+dy[dir], ny, n))
				turn_flag |= str[ny][nx+dy[dir]] == '#';
			if(in(nx        , ny, n))
				turn_flag |= str[ny][nx        ] == '#';
			if(in(nx-dy[dir], ny, n))
				turn_flag |= str[ny][nx-dy[dir]] == '#';

			if(!in(nx,ny,n))
				turn_flag = true;

			if(turn_flag) {
				if(flag)
					break;
				dir = (dir + 1) % 4;
				flag = true;
			}
			else {
				x += dx[dir];
				y += dy[dir];
				flag = false;
			}
		}

		if(t > 0)
			cout << endl;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++)
				cout << str[i][j];
			cout << endl;
		}
	}
}
### Prompt

Develop a solution in Cpp to the problem described below:

I decided to create a program that displays a "round and round pattern". The "round and round pattern" is as follows.

* If the length of one side is n, it is displayed as a character string with n rows and n columns.
* A spiral pattern that rotates clockwise with the lower left corner as the base point.
* The part with a line is represented by # (half-width sharp), and the blank part is represented by "" (half-width blank).
* Leave a space between the lines.



Create a program that takes an integer n as an input and outputs a "round and round pattern" with a side length of n.



Input

The input is given in the following format:


d
n1
n2
::
nd


The number of datasets d (d ≤ 20) is given to the first line, and the side length ni (1 ≤ ni ≤ 100) of the i-th round pattern is given to each of the following d lines.

Output

Please output a round and round pattern for each data set. Insert a blank line between the datasets.

Example

Input

2
5
6


Output

#####
#   #
# # #
# # #
# ###

######
#    #
# ## #
# #  #
# #  #
# ####

### Response

```cpp
#include <iostream>
using namespace std;

bool in(int x, int y, int n) {
	return 0 <= x && x < n && 0 <= y && y < n;
}

int main() {
	int d;
	cin >> d;
	for(int t = 0; t < d; t++) {
		char str[128][128];
		int n;
		cin >> n;

		for(int i = 0; i < 128; i++)
			for(int j = 0; j < 128; j++)
				str[i][j] = ' ';

		int x = 0, y = n - 1;
		int dir = 0;
		int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
		bool flag = false;
		while(1) {
			str[y][x] = '#';
			/*
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++)
					cout << ((i == y && j == x) ? '*' : str[i][j]);
				cout << endl;
			}
			cout << (dir == 0 ? "up" : dir == 1 ? "forward" : dir == 2 ? "down" : "back") << endl;
			cout << endl;
			*/

			int nx, ny;
			bool turn_flag = false;
			nx = x + dx[dir]; ny = y + dy[dir];

			if(in(nx+dx[dir], ny+dx[dir], n))
				turn_flag |= str[ny+dx[dir]][nx+dx[dir]] == '#';
			if(in(nx+dx[dir], ny        , n))
				turn_flag |= str[ny        ][nx+dx[dir]] == '#';
			if(in(nx+dx[dir], ny-dx[dir], n))
				turn_flag |= str[ny-dx[dir]][nx+dx[dir]] == '#';

			if(in(nx, ny+dx[dir], n))
				turn_flag |= str[ny+dx[dir]][nx] == '#';
			if(in(nx, ny        , n))
				turn_flag |= str[ny        ][nx] == '#';
			if(in(nx, ny-dx[dir], n))
				turn_flag |= str[ny-dx[dir]][nx] == '#';

			if(in(nx+dy[dir], ny+dy[dir], n))
				turn_flag |= str[ny+dy[dir]][nx+dy[dir]] == '#';
			if(in(nx        , ny+dy[dir], n))
				turn_flag |= str[ny+dy[dir]][nx        ] == '#';
			if(in(nx-dy[dir], ny+dy[dir], n))
				turn_flag |= str[ny+dy[dir]][nx-dy[dir]] == '#';

			if(in(nx+dy[dir], ny, n))
				turn_flag |= str[ny][nx+dy[dir]] == '#';
			if(in(nx        , ny, n))
				turn_flag |= str[ny][nx        ] == '#';
			if(in(nx-dy[dir], ny, n))
				turn_flag |= str[ny][nx-dy[dir]] == '#';

			if(!in(nx,ny,n))
				turn_flag = true;

			if(turn_flag) {
				if(flag)
					break;
				dir = (dir + 1) % 4;
				flag = true;
			}
			else {
				x += dx[dir];
				y += dy[dir];
				flag = false;
			}
		}

		if(t > 0)
			cout << endl;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++)
				cout << str[i][j];
			cout << endl;
		}
	}
}
```