#include <iostream>
#include <vector>

using namespace std;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

inline int next(int d)
{
    return (d + 1) % 4;
}

int main()
{
    int dataset, n;

    cin >> dataset;
    for (int cnt = 0; cnt < dataset; ++cnt) {
        if (cnt != 0)
            cout << "\n";
        cin >> n;

        if (n == 1) {
            cout << "#\n";
            continue;
        }
        else if (n == 2) {
            cout << "##\n# \n";
            continue;
        }
        else if (n == 3) {
            cout << "###\n# #\n# #\n";
            continue;
        }

        vector<vector<bool> > map(n, vector<bool>(n, false));
        int d = 0, x = 0, y = n - 1;
        bool flag = true;

        while (flag) {
            map[y][x] = true;

            int nx = x + dx[d];
            int ny = y + dy[d];

            if (nx < 0 || nx >= n || ny < 0 || ny >= n) {
                d = next(d);
                x += dx[d];
                y += dy[d];
                continue;
            }

            for (int i = 0; i < 4; ++i) {
                if ((i + 2) % 4 == d)
                    continue;
                int nnx = nx + dx[i];
                int nny = ny + dy[i];

                if (nnx < 0 || nnx >= n || nny < 0 || nny >= n)
                    continue;
                if (map[nny][nnx]) {
                   d =  next(d);
                   break;
                }
            }
            x += dx[d];
            y += dy[d];

            for (int i = 0; i < 4; ++i) {
                if ((i + 2) % 4 == d)
                    continue;
                nx = x + dx[i];
                ny = y + dy[i];

                if (nx < 0 || nx >= n || ny < 0 || ny >= n)
                    continue;
                if (map[ny][nx]) {
                    flag = false;
                    break;
                }
            }
        }

        // Output
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (map[i][j])
                    cout << "#";
                else
                    cout << " ";
            }
            cout << "\n";
        }
    }

    return 0;
}
### Prompt

Generate a CPP solution 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 <vector>

using namespace std;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

inline int next(int d)
{
    return (d + 1) % 4;
}

int main()
{
    int dataset, n;

    cin >> dataset;
    for (int cnt = 0; cnt < dataset; ++cnt) {
        if (cnt != 0)
            cout << "\n";
        cin >> n;

        if (n == 1) {
            cout << "#\n";
            continue;
        }
        else if (n == 2) {
            cout << "##\n# \n";
            continue;
        }
        else if (n == 3) {
            cout << "###\n# #\n# #\n";
            continue;
        }

        vector<vector<bool> > map(n, vector<bool>(n, false));
        int d = 0, x = 0, y = n - 1;
        bool flag = true;

        while (flag) {
            map[y][x] = true;

            int nx = x + dx[d];
            int ny = y + dy[d];

            if (nx < 0 || nx >= n || ny < 0 || ny >= n) {
                d = next(d);
                x += dx[d];
                y += dy[d];
                continue;
            }

            for (int i = 0; i < 4; ++i) {
                if ((i + 2) % 4 == d)
                    continue;
                int nnx = nx + dx[i];
                int nny = ny + dy[i];

                if (nnx < 0 || nnx >= n || nny < 0 || nny >= n)
                    continue;
                if (map[nny][nnx]) {
                   d =  next(d);
                   break;
                }
            }
            x += dx[d];
            y += dy[d];

            for (int i = 0; i < 4; ++i) {
                if ((i + 2) % 4 == d)
                    continue;
                nx = x + dx[i];
                ny = y + dy[i];

                if (nx < 0 || nx >= n || ny < 0 || ny >= n)
                    continue;
                if (map[ny][nx]) {
                    flag = false;
                    break;
                }
            }
        }

        // Output
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (map[i][j])
                    cout << "#";
                else
                    cout << " ";
            }
            cout << "\n";
        }
    }

    return 0;
}
```