#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct point
{
int i,j;
int num;
char c;
}p[1000];
int find(char n)
{
if(n=='a') return 2;
if(n=='b') return 6;
if(n=='c') return 10;
if(n=='d') return 14;
if(n=='e') return 18;
if(n=='f') return 22;
if(n=='g') return 26;
if(n=='h') return 30;
}
int ok(char n)
{
if(n=='1') return 15;
if(n=='2') return 13;
if(n=='3') return 11;
if(n=='4') return 9;
if(n=='5') return 7;
if(n=='6') return 5;
if(n=='7') return 3;
if(n=='8') return 1;
}
int main()
{
int i,j,n,m,k;
char s[17][35]={ {"+---+---+---+---+---+---+---+---+"},
{"|...|:::|...|:::|...|:::|...|:::|"},
{ "+---+---+---+---+---+---+---+---+"},
{"|:::|...|:::|...|:::|...|:::|...|"},
{"+---+---+---+---+---+---+---+---+"},
{"|...|:::|...|:::|...|:::|...|:::|"},
{"+---+---+---+---+---+---+---+---+"},
{"|:::|...|:::|...|:::|...|:::|...|"},
{"+---+---+---+---+---+---+---+---+"},
{"|...|:::|...|:::|...|:::|...|:::|"},
{ "+---+---+---+---+---+---+---+---+"},
{ "|:::|...|:::|...|:::|...|:::|...|"},
{"+---+---+---+---+---+---+---+---+"},
{"|...|:::|...|:::|...|:::|...|:::|"},
{"+---+---+---+---+---+---+---+---+"},
{"|:::|...|:::|...|:::|...|:::|...|"},
{ "+---+---+---+---+---+---+---+---+"} }; char s1[1005],s2[1005],c;
char st[10];
scanf("%s",st);
getchar();
gets(s1);
m=strlen(s1);
int sum=0,a,b;
for(i=0;i<m;i++)
{
sum++;
if(s1[i]==',' || i==m-1)
{
if(sum==4)
{
a=find(s1[i-2]);
b=ok(s1[i-1]);
s[b][a]=s1[i-3];
}
if(sum==3 && i!=m-1)
{
a=find(s1[i-2]);
b=ok(s1[i-1]);
s[b][a]='P';
}
if(i==m-1)
{
if(sum==2)
{
a=find(s1[i-1]);
b=ok(s1[i]);
s[b][a]='P';
}
if(sum==3)
{
a=find(s1[i-1]);
b=ok(s1[i]);
s[b][a]=s1[i-2];
}
}
sum=0;
}
}
scanf("%s",st);
getchar();
gets(s2);
m=strlen(s2);
sum=0;
for(i=0;i<m;i++)
{
sum++;
if(s2[i]==',' || i==m-1)
{
if(sum==4)
{
a=find(s2[i-2]);
b=ok(s2[i-1]);
s[b][a]=s2[i-3]+32;
}
if(sum==3 && i!=m-1)
{
a=find(s2[i-2]);
b=ok(s2[i-1]);
s[b][a]='p';
}
if(i==m-1)
{
if(sum==2)
{
a=find(s2[i-1]);
b=ok(s2[i]);
s[b][a]='p';
}
if(sum==3)
{
a=find(s2[i-1]);
b=ok(s2[i]);
s[b][a]=s2[i-2]+32;
}
}
sum=0;
}
}
for(i=0;i<17;i++)
printf("%s\n",s[i]);
return 0;
}