#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int m,n,x,y,p,xx,yy,d,l,o;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int main(){
  cin>>m;
  while(m--){
   if(o++)cout<<endl;
    cin>>n;l=0;
    string s[n];
    r(i,n)r(j,n)s[i]+='#';
    s[n-1][1]=' ';
    xx=0,yy=n-1,d=0;
    while(1){
      int c=0;
      r(i,4){
        if(!l)c--;
        y=dy[i]+yy,x=dx[i]+xx;
        if(y<0||y>=n||x<0||x>=n){
          c++;
          continue;
        }
        else if(s[y][x]==' ')c++;
      }
      if(c>=3)break;
      y=dy[d]+yy,x=dx[d]+xx;
      if(y<0||y>=n||x<0||x>=n)d=(d+1)%4;
      else if(s[y][x]==' ')d=(d+1)%4;
      else{
        yy=y+dy[d],xx=x+dx[d];
        if(yy>=0&&yy<n&&xx>=0&&xx<n&&s[yy][xx]!=' '){
          p=(d+1)%4;
          yy=y+dy[p],xx=x+dx[p];
          s[yy][xx]=' ';
        }
        yy=y,xx=x;
      }l++;
    }
    r(i,n)cout<<s[i]<<endl;
  }
}
### 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<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int m,n,x,y,p,xx,yy,d,l,o;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int main(){
  cin>>m;
  while(m--){
   if(o++)cout<<endl;
    cin>>n;l=0;
    string s[n];
    r(i,n)r(j,n)s[i]+='#';
    s[n-1][1]=' ';
    xx=0,yy=n-1,d=0;
    while(1){
      int c=0;
      r(i,4){
        if(!l)c--;
        y=dy[i]+yy,x=dx[i]+xx;
        if(y<0||y>=n||x<0||x>=n){
          c++;
          continue;
        }
        else if(s[y][x]==' ')c++;
      }
      if(c>=3)break;
      y=dy[d]+yy,x=dx[d]+xx;
      if(y<0||y>=n||x<0||x>=n)d=(d+1)%4;
      else if(s[y][x]==' ')d=(d+1)%4;
      else{
        yy=y+dy[d],xx=x+dx[d];
        if(yy>=0&&yy<n&&xx>=0&&xx<n&&s[yy][xx]!=' '){
          p=(d+1)%4;
          yy=y+dy[p],xx=x+dx[p];
          s[yy][xx]=' ';
        }
        yy=y,xx=x;
      }l++;
    }
    r(i,n)cout<<s[i]<<endl;
  }
}
```