#include <iostream>
using namespace std;
 
int main() {
	int n, x;
	cin >> n;
	for (int l = 0; l < n; l ++){
		cin >> x;
		for (int j = 0; j < x; j ++){
			for (int i = 0; (i <= j) or (i <= x - 1 - j); i ++){
				if ((i == j) or (j == x - 1 - i)) cout << "X";
				else cout << " ";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}