// Thomas Meeks
// 6/6/2023
// Problem: 
// Multiple test cases.
// For each test case you are given a single value n
// draw an X shape of '#' that is of size n
// For example:
// n = 5
// #   #
//  # # 
//   #  
//  # # 
// #   #
#include <iostream>
using namespace std;
int main(){
  int cases; cin >> cases;
  //Take in number of cases
  //cases-- also returns the value of cases after the change is made
  //the integer 0 evaluates to boolean false so while(cases--)
  //is a short and easy way to go through number of cases
  while(cases--){
    //Take in dimensions of X
    int dim; cin >> dim;
    //We will need to either output a space or a # for every
    //square in the bounding box so we can use a nested for-loop
    //A square will be on the diagnal going from top left
    //to bottom right if its row is equal to col (or row-col = 0)
    //a square will be on the diagnal going from bottom left
    //to top right if row+col is equal to dim-1 (draw a picture!)

    //double for loop
    for(int row = 0; row < dim; row++){
      for(int col = 0; col < dim; col++){
        //if statement to check if we should output a # or a space
        if(row==col || row+col == (dim-1))
          cout << "#";
        else
          cout << " ";
      }
      //We need to output a new line after printing the single line
      //for each layer of the X
      //'\n' is considerably faster then endl as it avoids output          flushing for every line of output
      cout << '\n';
    }
  }

  return 0;
}