#include <iostream>
using namespace std;
int d[12][12]={},n;
void cal(int X,int Y,int num,int R){
	if(num<=n*n){
		d[X][Y]=num;
		num++;
		int RR;
		if(R==1){
			X++;
			if(Y==1)RR=2;
			else RR=3;
		}
		else if(R==2){
			X--,Y++;
			if(X==1 && Y==n)RR=1;
			else if(X==1)RR=4;
			else if(Y==n)RR=1;
			else RR=2;
		}
		else if(R==3){
			X++,Y--;
			if(Y==1 && X==n)RR=4;
			else if(Y==1)RR=1;
			else if(X==n)RR=4;
			else RR=3;
		}
		else if(R==4){
			Y++;
			if(X==1)RR=3;
			else RR=2;
		}
		cal(X,Y,num,RR);
	}
}
int main(){
	int Case=1;
	while(cin>>n,n){
		cout<<"Case "<<Case<<":"<<endl;
		cal(1,1,1,1);
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(d[j][i]>99)cout<<d[j][i];
				else if(d[j][i]>9)cout<<" "<<d[j][i];
				else cout<<"  "<<d[j][i];
			}
			cout<<endl;
		}
		Case++;
	}
	return 0;
}
