#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
	int n, i, j, x, y, tmp, nn, t = 1;
	int **array;
	
	while(1){
		scanf("%d", &n);
		nn = n*n;
		if(n == 0){
			break;
		}
		
		array = (int **)calloc(n, sizeof(int));
		for(i = 0; i < n; i++){
			array[i] = (int *)calloc(n, sizeof(int));
		}
		x = j = array[0][0] = 1;
		tmp = 2;
		y = 0;
		i = -1;
		while(tmp <= nn){
			array[y][x] = tmp++;
			x += i;
			y += j;
			
			if(x < 0 || y < 0 || y >= n || x >= n){
				x -= i;
				y -= j;
				i = -i;
				j = -j;
				
				if((y == 0 || y == n-1)&& x < n-1){
					x++;
				} else {
					y++;
				}
			}
		}
		
		printf("Case %d:\n", t++);
		for(i = 0; i < n; i++){
			for(j = 0; j < n; j++){
				printf("%3d", array[i][j]);
			}
			printf("\n");
		}
		
		for(i = 0; i < n; i++){
			free(array[i]);
		}
		free(array);
	}
	
	
	return 0;
}