#include
int main(int argc, char *argv[])
{char c='1',i,j;
scanf("%c%*c",&c);
while(c!='#')
{printf("case %c:\n",c);
for(i=c;i>='A';i--)
{printf("%*s",c-i,"");
for(j='A';j<=i;j++)
printf("%c",j);
for(j-=2;j>='A';j--)
printf("%c",j);
printf("\n");
}
scanf("%c%*c",&c);
}
return 0;
}