import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int n, num;
	while (n = readln.chomp.to!int, n) {
		num++;
		auto mat = new int[][](n, n);
		mat[0][0] = 1;
		int cnt = 1, x, y;
		bool gd;
		while (cnt != n*n) {
			int nx, ny;
			bool f;
			if (gd) {
				nx = x - 1;
				ny = y + 1;
				if (ny >= n) {
					nx += 2;
					ny--;
					f = 1;
				} else if (nx < 0) {
					nx++;
					f = 1;
				}
			} else {
				nx = x + 1;
				ny = y - 1;
				if (nx >= n) {
					nx--;
					ny += 2;
					f = 1;
				} else if (ny < 0) {
					ny++;
					f = 1;
				}
			}
			if (f) gd = !gd;
			mat[nx][ny] = mat[x][y] + 1;
			x = nx;
			y = ny;
			cnt++;
		}
		writeln("Case ", num, ":");
		foreach (i; 0..n) {
			foreach (j; 0..n) {
				writef("%3d", mat[j][i]);
			}
			writeln("");
		}
	}
}