#include<stdio.h>
#define d for(x=0;x<N;x++){for(y=0;y<N;y++){

m[10][10],c,x,y,N=10;
main(z){d m[x][y]=x?m[x-1][y+1]+1:y?m[x][y-1]+y:1;}}
  for(;scanf("%d",&N),N;){
    printf("Case %d:\n",++c);
    d printf("%3d",(z=x+y)<N?z%2?m[x][y]:m[y][x]:N*N+1-(z%2?m[N-1-x][N-1-y]:m[N-1-y][N-1-x]));}printf("\n");}}}