#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n, cnt = 0;
    while(cin >> n, n){
        cnt ++;
        int d[11][11] = {};
        d[0][0] = 1;
        int f = 0, y = 0, x = 0;
        rep(i, 2, n*n + 1){
            if(f == 0){
                if(x != n - 1) x++;
                else if(y != n - 1) y++;
                else break;
                f = 1;
            }else if(f == 1){
                y++; x--;
                if(x == 0 || y == n - 1) f = 2;
            }else if(f == 2){
                if(y != n - 1) y++;
                else if(x != n - 1) x++;
                else break;
                f = 3; 
            }else if(f == 3){
                y--; x++;
                if(y == 0 || x == n - 1) f = 0;
            }
            d[y][x] = i;
        }
        cout << "Case " << cnt << ":" << endl;
        rep(i, 0, n){
            rep(j, 0, n){
                printf("%3d", d[i][j]);
            }
            cout << endl;
        }
    }
}