#include <stdio.h>

int main(void) {
  int x = 0, y = 0, side = 0, num = 0, index = 1;
  
  scanf("%d", &side);
  while (side != 0) {
    printf("Case %d:\n", index);
    index++;
    y = 0;
    while (y != side) {
      x = 0;
      while (x != side) {
	if (side > x + y)
	  num = 1 + (x + y + 1) % 2 * ((x + y + 1) * (x + y) / 2 + y) + (x + y + 2) % 2 * ((x + y + 1) * (x + y) / 2 + x);
	else
	  num = side * side - (x + y + 1) % 2 * ((side * 2 - (x + y + 1)) * (side * 2 - (x + y + 1) - 1) / 2 + side - (y + 1)) - (x + y + 2) % 2 * ((side * 2 - (x + y + 1)) * (side * 2 - (x + y + 1) - 1) / 2 + side - (x + 1));
	x++;
	if (num / 10 == 0)
	  printf("  %d", num);
	else
	  printf(" %d", num);
      }
      y++;
      putchar('\n');
    }
    scanf("%d", &side);
  }
  
  return(0);
}