#include <stdio.h>
#include <memory.h>
int main(void){
  int n,c,i,j,f,k=1,a[11][11];
  while(1){
    scanf("%d",&n);
    if(!n)
      break;
    memset(a,0,sizeof(a));
    i=j=1;
    f=0;
    c=1;
    while(c<=n*n/2){
      if(f%4==0){
	  a[i][j]=c;
	  a[n-i+1][n-j+1]=n*n-c+1;
	  j++;
	  c++;
	  f++;
      }
      else if(f%4==1){
	while(j>1){
	  a[i][j]=c;
	  a[n-i+1][n-j+1]=n*n-c+1;
	  i++;
	  j--;
	  c++;
	}
	f++;
      }
      else if(f%4==2){
	a[i][j]=c;
	a[n-i+1][n-j+1]=n*n-c+1;
	i++;
	c++;
	f++;
      }
      else if(f%4==3){
	while(i>1){
	  a[i][j]=c;
	  a[n-i+1][n-j+1]=n*n-c+1;
	  i--;
	  j++;
	  c++;
	}
	f++;
      }
    }
    printf("Case %d:\n",k++);
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	printf("%3d",a[i][j]);
      }
      puts("");
    }
  }
  return 0;
}