#include<stdio.h>
int main(){
  int n,i,j,d[10][10],a,c=1;
  while(scanf("%d",&n),n){
    a=1;
    for(i=0;i<2*n;i++){
      if(i%2){
	for(j=0;j<n;j++){printf(" %d %d\n",j,i-j);
	  if(i-j<0)continue;
	  if(n<=i-j)continue;
	  d[j][i-j]=a++;
	}
      }
      else{
	for(j=n-1;j>-1;j--){printf("%d %d\n",j,i-j);
	  if(i-j<0)continue;
	  if(n<=i-j)continue;
	  d[j][i-j]=a++;
	}
      }
      if(n*n<a)break;
    }
    printf("Case %d:\n",c++);
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%3d",d[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}