#include <stdio.h>


int main (void) {
    int N, m[10][10], x, v, r, c, dr, dc;

    for (x = 1; scanf("%d\n", &N) != EOF && N; x++) {
        r = 0;
        c = 0;
        dr = -1;
        dc = 1;
        for (v = 1; v <= N * N; v++) {
            if (r >= N) {
                r -= 1;
                c += 2;
                dr *= -1;
                dc *= -1;
            }
            else if (c >= N) {
                r += 2;
                c -= 1;
                dr *= -1;
                dc *= -1;
            }
            else if (r < 0) {
                r += 1;
                dr *= -1;
                dc *= -1;
            }
            else if (c < 0) {
                c += 1;
                dr *= -1;
                dc *= -1;
            }
            m[r][c] = v;
            r += dr;
            c += dc;
        }

        printf("Case %d:\n", x);
        for (r = 0; r < N; r++) {
            for (c = 0; c < N; c++) {
                printf("%3d", m[r][c]);
            }
            puts("");
        }

    }
}