//* Problem  : 1722.   Manhattan 2025 
//* Contest  : acm.tju.edu.cn/toj
//* Type     : Solution
//* Date     : 2008.07.20
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <queue>

using namespace std;

#define int64 long long
#define MP(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define SZ(a) (int)a.size()
#define FOR(i, n) for (int i = 0; i < (int)n; i++)
#define INF 1000*1000*1000
#define ALL(a) a.begin(), a.end()

#define int64 long long

char a[32][32][32];

int n;

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

void solve()
{
	int x = n, y = n, z = n;
	a[x][y][z] = '0';
	queue <int> qx, qy, qz;
	qx.push(x);
	qy.push(y);
	qz.push(z);
	while (!qx.empty())
	{
		x = qx.front(); qx.pop();
		y = qy.front(); qy.pop();
		z = qz.front(); qz.pop();
		if (a[x][y][z] == n + '0') continue;
		for (int i = 0; i < 6; i++)
		{
			int xx = dx[i] + x;
			int yy = dy[i] + y;
			int zz = dz[i] + z;
			if (!a[xx][yy][zz])
			{
				a[xx][yy][zz] = a[x][y][z] + 1;
				qx.push(xx);
				qy.push(yy);
				qz.push(zz);
			}
		}
	}
}

void result()
{
	for (int i = 0; i < 2 * n + 1; i++)
	{
		printf("slice #%d:\n", i + 1);
		for (int j = 0; j < 2 * n + 1; j++)
		{
			for (int t = 0; t < 2 * n + 1; t++)
				if (!a[i][j][t])
					a[i][j][t] = '.';
			printf("%s\n", a[i][j]);
		}
	}
}

int main()
{
#ifdef _DEBUG
	freopen("1064", "r", stdin);
#endif
	int nt; scanf("%d", &nt);
	for (int it = 1; it <= nt; it++)
	{
		printf("Scenario #%d:\n", it);
		memset(a, 0, sizeof(a));
		scanf("%d", &n);
		n = min(n, 9);
		solve();
		result();
		printf("\n");
	}
	return 0;
}

