#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<deque>
using namespace std;

int main() {

    int n;
    int time = 0;
    while(cin >> n) {
        if (n == 0) break;
        time += 1;
        bool ascending = true;
        vector<vector<int> > jpeg (n, vector<int>(n));
        int x = 0;
        int y = 0;

        for (int i = 1; i <= n * n; i++) {
            jpeg[x][y] = i;
            if ( ascending && y == 0 && x != n-1 )  {
                x += 1;
                ascending = false;
            } else if ( (!ascending) && x == 0 && y != n-1) {
                y += 1;
                ascending = true;
            } else if ( ascending && x == n-1) {
                y += 1;
                ascending = false;
            } else if ( (!ascending) && y == n-1) {
                x += 1;
                ascending = true;
            } else if (ascending) {
                x += 1;
                y -= 1;
            } else {
                x -= 1;
                y += 1;
            }
        }

        cout << "Case " << time << ":" << endl;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                printf("%3d", jpeg[j][i]);
            }
            cout << endl;
        }
    }
     
    return 0;
}