#include <cstring>
#include <iostream>

using namespace std;

int n;
char pattern[104][104];

void rec(int d, bool c, int y, int x) {
  pattern[y][x] = '#';
  switch (d) {
  case 0:
    if (pattern[y-2][x] == '#')
      if (c && pattern[y+1][x+1] != '#') rec(1, false, y, x);
      else return;
    else
      rec(0, true, y-1, x);
    break;
  case 1:
    if (pattern[y][x+2] == '#')
      if (c && pattern[y+1][x-1] != '#') rec(2, false, y, x);
      else return;
    else
      rec(1, true, y, x+1);
    break;
  case 2:
    if (pattern[y+2][x] == '#')
      if (c && pattern[y-1][x-1] != '#') rec(3, false, y, x);
      else return;
    else
      rec(2, true, y+1, x);
    break;
  case 3:
    if (pattern[y][x-2] == '#')
      if (c && pattern[y-1][x+1] != '#') rec(0, false, y, x);
      else return;
    else
      rec(3, true, y, x-1);
    break;
  default:
    break;
  }
}

int main() {
  int d;
  cin >> d;
  for (int i = 0; i < d; i++) {
    memset(pattern, ' ', sizeof pattern);
    cin >> n;
    for (int j = 0; j < n+4; j++)
      pattern[0][j] = pattern[n+3][j] = pattern[j][0] = pattern[j][n+3] = '#';
    rec(0, true, n+1, 2);
    for (int y = 2; y < n+2; y++) {
      for (int x = 2; x < n+2; x++)
        cout << pattern[y][x];
      cout << endl;
    }
    if (i != d-1) cout << 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 <cstring>
#include <iostream>

using namespace std;

int n;
char pattern[104][104];

void rec(int d, bool c, int y, int x) {
  pattern[y][x] = '#';
  switch (d) {
  case 0:
    if (pattern[y-2][x] == '#')
      if (c && pattern[y+1][x+1] != '#') rec(1, false, y, x);
      else return;
    else
      rec(0, true, y-1, x);
    break;
  case 1:
    if (pattern[y][x+2] == '#')
      if (c && pattern[y+1][x-1] != '#') rec(2, false, y, x);
      else return;
    else
      rec(1, true, y, x+1);
    break;
  case 2:
    if (pattern[y+2][x] == '#')
      if (c && pattern[y-1][x-1] != '#') rec(3, false, y, x);
      else return;
    else
      rec(2, true, y+1, x);
    break;
  case 3:
    if (pattern[y][x-2] == '#')
      if (c && pattern[y-1][x+1] != '#') rec(0, false, y, x);
      else return;
    else
      rec(3, true, y, x-1);
    break;
  default:
    break;
  }
}

int main() {
  int d;
  cin >> d;
  for (int i = 0; i < d; i++) {
    memset(pattern, ' ', sizeof pattern);
    cin >> n;
    for (int j = 0; j < n+4; j++)
      pattern[0][j] = pattern[n+3][j] = pattern[j][0] = pattern[j][n+3] = '#';
    rec(0, true, n+1, 2);
    for (int y = 2; y < n+2; y++) {
      for (int x = 2; x < n+2; x++)
        cout << pattern[y][x];
      cout << endl;
    }
    if (i != d-1) cout << endl;
  }
}
```