#include <iostream>
#include <cstdio>
using namespace std;
int da[20][20];
char G[200][200];
//抄博友程序 模拟 背
//11 2*4+3; 7 2*4-1;
//19 15
int main()
{
int tag=0;
while(1)
{
int n;
cin>>n;
if(n==0)
{
break;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cin>>da[i][j];
}
}
for(int i=1;i<=n*4-1;i++)//wa 点
{
for(int j=1;j<=n*4+3;j++)
{
G[i][j]=' ';
}
}
for(int i=1;i<=n*4-1;i++)
{
for(int j=1;j<=n*4+3;j++)
{
if(i==1 ||i==n*4-1)
{
G[i][j]='*';
}else
{
if(j==1||j==(n*4+3))
{
G[i][j]='*';
}else
{
if(i%4==2)
{
if(j%4==2)
{
G[i][j]='H';
}else if(j%4==0)
{
G[i][j]='O';
}
}else if(i%4==0)
{
if(j%4==0)
{
G[i][j]='H';
}
}
}
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(da[i][j]==1)
{
G[i*4-2][j*4-1]='-';
G[i*4-2][j*4+1]='-';
}else if(da[i][j]==-1)
{
G[i*4-1][j*4]='|';
G[i*4-3][j*4]='|';
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(da[i][j]==0)
{
if(j==1)
{
G[i*4-2][j*4-1]='-';
}
if(i==1)
{
G[i*4-1][j*4]='|';
}
if(j!=1)
{
if(G[i*4-2][j*4-3]=='-')
{
G[i*4-2][j*4+1]='-';
}else
{
G[i*4-2][j*4-1]='-';
}
}
if(i!=1)
{
if(G[i*4-5][j*4]=='|')
{
G[i*4-1][j*4]='|';
}else
{
G[i*4-3][j*4]='|';
}
}
}
}
}
if (tag)//抄博友程序
cout<<endl;
cout<<"Case "<<++tag<<":"<<endl<<endl;
for(int i=1;i<=n*4-1;i++)
{
for(int j=1;j<=n*4+3;j++)
{
cout<<G[i][j];
}
cout<<endl;
}
//cout<<endl;
}
return 0;
}