#include<iostream>
#include<cstring>
using namespace std;

int n;
char c[999][999];
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

bool chk(int y, int x){
  if(y > -1 && x > -1 && y < n+2 && x < n+2 && c[y][x] != ' ') return true;
  return false;
}

void solve(int y, int x, int p){

  int py = y + dy[p], px = x + dx[p];
  int pyy = y + dy[p]*3, pxx = x + dx[p]*3;
  
  if(n == 1){ c[y][x] = '#'; return; }
  if(y < 0 || x < 0 || y == n || x == n || c[y][x] != ' ') return;
  for(int i=0;i<4;i++) if(c[py][px] != ' ' && (i+2)%4 != p) return;
  
  c[y][x] = '#';
  
  if((!py || chk(pyy, pxx)) && !p) p++;
  else if((px == n-1 || chk(pyy, pxx)) && p == 1) p++;
  else if((py == n-1 || chk(pyy, pxx)) && p == 2) p++;
  else if((!px || chk(pyy, pxx)) && p == 3) p = 0;
  
  solve(py, px, p);
}

int main(){

  int l;
  cin >> l;
  while(l--){
    memset(c, ' ', sizeof(c));
    cin >> n;
    solve(n-1,0,0);
    for(int i=0;i<n;i++) c[i][n] = '\0', cout << c[i] << endl;
    if(l) 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>
#include<cstring>
using namespace std;

int n;
char c[999][999];
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

bool chk(int y, int x){
  if(y > -1 && x > -1 && y < n+2 && x < n+2 && c[y][x] != ' ') return true;
  return false;
}

void solve(int y, int x, int p){

  int py = y + dy[p], px = x + dx[p];
  int pyy = y + dy[p]*3, pxx = x + dx[p]*3;
  
  if(n == 1){ c[y][x] = '#'; return; }
  if(y < 0 || x < 0 || y == n || x == n || c[y][x] != ' ') return;
  for(int i=0;i<4;i++) if(c[py][px] != ' ' && (i+2)%4 != p) return;
  
  c[y][x] = '#';
  
  if((!py || chk(pyy, pxx)) && !p) p++;
  else if((px == n-1 || chk(pyy, pxx)) && p == 1) p++;
  else if((py == n-1 || chk(pyy, pxx)) && p == 2) p++;
  else if((!px || chk(pyy, pxx)) && p == 3) p = 0;
  
  solve(py, px, p);
}

int main(){

  int l;
  cin >> l;
  while(l--){
    memset(c, ' ', sizeof(c));
    cin >> n;
    solve(n-1,0,0);
    for(int i=0;i<n;i++) c[i][n] = '\0', cout << c[i] << endl;
    if(l) cout << endl;
  }
}
```