#include <iostream>
#include <string>
#include <vector>
#include <cstring>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	int a[101][101];
	int dx[4] = {0,1,0,-1};
	int dy[4] = {-1,0,1,0};
	
	bool first = true;

	rep(i,n)
	{
		int r;
		cin >> r;
		int r2 = r;

		memset(a,0,sizeof(a));

		if(r == 1)
		{
			if(first) first = false;
			else cout << endl;
			cout << "#" << endl;
		}
		else if(r == 2)
		{
			if(first) first = false;
			else cout << endl;
			cout << "##" << endl << "# " << endl;
		}
		else
		{
			int y = r-1;
			int x = 0;
			a[y][x] = 1;

			int dir = 0;

			rep(j,r-1)
			{
				y += dy[dir%4];
				x += dx[dir%4];
				a[y][x] = 1;
			}

			dir++;
			r--;
			
			if(r%2 == 1)
			{
				while(true)
				{
					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}
					dir++;

					if(r == 1) break;

					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}
					dir++;
					r -= 2;
				}
			}
			else
			{
				while(true)
				{
					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}
					dir++;

					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}

					if(r == 2 ) break;

					dir++;
					r -= 2;
				}
			}
			
			if(first) first = false;
			else cout << endl;

			rep(j,r2)
			{
				rep(k,r2)
				{
					if(a[j][k] == 1) cout << "#";
					else cout << " ";
				}
				cout << endl;
			}
		}	
	}
	return 0;
}
### Prompt

Please create a solution in cpp to the following problem:

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>
#include <string>
#include <vector>
#include <cstring>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	int a[101][101];
	int dx[4] = {0,1,0,-1};
	int dy[4] = {-1,0,1,0};
	
	bool first = true;

	rep(i,n)
	{
		int r;
		cin >> r;
		int r2 = r;

		memset(a,0,sizeof(a));

		if(r == 1)
		{
			if(first) first = false;
			else cout << endl;
			cout << "#" << endl;
		}
		else if(r == 2)
		{
			if(first) first = false;
			else cout << endl;
			cout << "##" << endl << "# " << endl;
		}
		else
		{
			int y = r-1;
			int x = 0;
			a[y][x] = 1;

			int dir = 0;

			rep(j,r-1)
			{
				y += dy[dir%4];
				x += dx[dir%4];
				a[y][x] = 1;
			}

			dir++;
			r--;
			
			if(r%2 == 1)
			{
				while(true)
				{
					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}
					dir++;

					if(r == 1) break;

					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}
					dir++;
					r -= 2;
				}
			}
			else
			{
				while(true)
				{
					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}
					dir++;

					rep(j,r)
					{
						y += dy[dir%4];
						x += dx[dir%4];
						a[y][x] = 1;
					}

					if(r == 2 ) break;

					dir++;
					r -= 2;
				}
			}
			
			if(first) first = false;
			else cout << endl;

			rep(j,r2)
			{
				rep(k,r2)
				{
					if(a[j][k] == 1) cout << "#";
					else cout << " ";
				}
				cout << endl;
			}
		}	
	}
	return 0;
}
```