// Arup Guha
// 1/17/2014
// Solution to 2009 UCF Locals Problem: Sierpinski Triangle

import java.util.*;

public class triangle {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Allocate space for the grid.
			int n = stdin.nextInt();
			char[][] grid = new char[1 << n][1 << n];
			for (int i=0; i<grid.length; i++)
				Arrays.fill(grid[i], ' ');

			// Run the fractal.
			fillTriRec(grid, 0, 0, n);

			// Print.
			System.out.println("Triangle #"+loop+":");
			print(grid);
			System.out.println();
		}
	}

	// Recursively fill the grid with a triangle starting at (startX, startY) with the given size.
	public static void fillTriRec(char[][] grid, int startX, int startY, int size) {

		// 2 x 2 square, so fill.
		if (size == 1) {
			for (int i=startX; i<startX+2; i++)
				for (int j=startY; j<startY+2; j++)
					grid[i][j] = 'X';
			return;
		}

		// These to relative offsets are important.
		int quarter = (1 << (size-2));
		int half = 2*quarter;

		// Recursively draw three triangles of size size-1.
		fillTriRec(grid, startX, startY+quarter, size-1);
		fillTriRec(grid, startX+half, startY, size-1);
		fillTriRec(grid, startX+half, startY+half, size-1);
	}

	public static void print(char[][] grid) {
		for (int i=0; i<grid.length; i++)
			System.out.println(new String(grid[i]));
	}
}