#include<stdio.h>

void ScanningUp(void);
void ScanningDown(void);

int x, y, count, data[9][9];

int main(){
  int i, j, n, updown, casecount=1;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;

    x = 0;
    y = 0;
    count = 0;
    updown = 1;

    while(1){
      if(updown == 1){
        ScanningUp();
        updown = 0;
        if(count == n*n) break;
        else if(y == n-1) x++;
        else if(x == 0) y++;
      }else{
        ScanningDown();
        updown = 1;
        if(x == n-1) y++;
        else if(y == 0) x++;
      }
    }

    printf("Case %d:\n", casecount);
    for(i=0; i<n; i++){
      for(j=0; j<n; j++)
        printf("%3d", data[i][j]);
      printf("\n");
    }

    casecount++;
  }

  return 0;
}

void ScanningUp(void){
  int n, m;
  n = x;
  m = y;
  while(1){
    count++;
    data[x][y] = count;
    if(x == m && y == n) break;
    x--;
    y++;
  }
}

 

void ScanningDown(void){
  int n, m;
  n = x;
  m = y;
  while(1){
    count++;
    data[x][y] = count;
    if(x == m && y == n) break;
    x++;
    y--;
  }
}