#include <stdio.h>
#include <string.h>
int main()
{
FILE *in,*out;
int ji=0,n,i,j[2];char c,s[10][2000];


in=fopen("input.txt","rt");
for (n=0;n<2;n++)
{
for (i=0,j[n]=0;fread(&c,1,1,in);)
{
if (c=='\n')break;
if (c=='}')i++;
else
 {
 if (j[n]<i) j[n]=i;
 i=0;
 }
}
if (j[n]<i) j[n]=i;
j[n]--;
}
j[0]=j[0]+j[1];
for(ji=0;ji<=j[0];ji++)
{
out=fopen("output.txt","w");
s[ji][0]='{';s[ji][1]=0;
for (i=0;i<ji;i++)
 {
 if (i!=0) strcat (s[ji],",");
 strcat(s[ji],s[i]);
 }
n=strlen(s[ji]);
strcat(s[ji],"}");s[ji][strlen(s[ji])]=0;
fwrite(s[ji],strlen(s[ji]),1,out);
}
fprintf(out,"\n");
}