#include<iostream>
using namespace std;
char hi[15][30];
int s;
string a;
int cnt=0;
int cc=0;
int change(char ch)
{
return ch-'0';
}
void print()
{
for(int i=0;i<2*s+3;i++)
{
cc=0;
for(string::iterator j=a.begin();j!=a.end();j++)
{
if(change(*j)==0)
for(int k=0;k<s+2;k++){
if(i==0||i==2*s+2)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else if(i==s+1)
{
cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else
{
if(k==0||k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
if(change(*j)==1)
for(int k=0;k<s+2;k++){
if(i==0||i==s+1||i==2*s+2)
{
cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(k!=s+1) cout<<" ";
else cout<<"|";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
if(change(*j)==2)
for(int k=0;k<s+2;k++){
if(i==0||i==s+1||i==2*s+2)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(i>0&&i<s+1)
{
if(k!=s+1) cout<<" ";
else cout<<"|";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else
{
if(k==0) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
}
if(change(*j)==3)
for(int k=0;k<s+2;k++){
if(i==0||i==s+1||i==2*s+2)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(k!=s+1) cout<<" ";
else cout<<"|";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
if(change(*j)==4)
for(int k=0;k<s+2;k++){
if(i==0||i==2*s+2)
{
cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else if(i==s+1){
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(i>0&&i<s+1)
{
if(k==0||k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else
{
if(k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
}
if(change(*j)==5)
for(int k=0;k<s+2;k++){
if(i==0||i==s+1||i==2*s+2)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(i>0&&i<s+1)
{
if(k==0) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
}
if(change(*j)==6)
for(int k=0;k<s+2;k++){
if(i==0||i==s+1||i==2*s+2)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(i>0&&i<s+1)
{
if(k==0) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(k==0||k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
}
if(change(*j)==7)
for(int k=0;k<s+2;k++){
if(i==0)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else if(i==s+1||i==2*s+2) {
cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else
{
if(k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
if(change(*j)==8)
for(int k=0;k<s+2;k++){
if(i==0||i==s+1||i==2*s+2)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else{
if(k==0||k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
if(change(*j)==9)
for(int k=0;k<s+2;k++){
if(i==0||i==s+1||i==2*s+2)
{
if(k==0||k==s+1) cout<<" ";
else cout<<"-";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else if(i>0&&i<s+1)
{
if(k==0||k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
else
{
if(k==s+1) cout<<"|";
else cout<<" ";
if(k==s+1&&cc<cnt-1) cout<<" ";
}
}
cc++;
}
cout<<endl;
}
cout<<endl;
}
int main()
{
while(cin>>s)
{
cin>>a;
if(s==0&&change(a[0])==0) break;
cnt=(int)a.length();
cc=0;
print();
cnt++;
}
return 0;
}