#include <stdio.h>

#define MAX 9

int main(void)
{
	int n, cnt, limit;
	int x, y, v;
	int result[MAX][MAX];
	int test_cnt;
	test_cnt = 0;

	while(scanf("%d", &n), n)
	{
		limit = n - 1;
		cnt = 1;
		x = y = 0;
		result[0][0] = cnt;
		while(n != 1)
		{
			if(x == limit) {
				v = -1;
				result[++y][x] = ++cnt;
			}
			else if(y == 0) {
				v = -1;
				result[y][++x] = ++cnt;
			}
			else if(y == limit) {
				v = 1;
				result[y][++x] = ++cnt;
			}
			else if(x == 0) {
				v = 1;
				result[++y][x] = ++cnt;
			}
			if((x == limit) && (y == limit)) break;
			y+= -v; x+= v;
			result[y][x] = ++cnt;
		}

		printf("Case %d:\n", ++test_cnt);
		for(y=0; y < n; y++) {
			for(x=0; x < n; x++) {
				printf("%3d", result[y][x]);
			}
			printf("\n");
		}
	}
	return 0;
}