#include <stdio.h>
#include <string.h>
#include <conio.h>

int main()
{
	clrscr();
	FILE *in;
	FILE *out;
	in=fopen("input.txt", "rt+");
	out=fopen("output.txt", "wt+");
	char txt1[1000], txt2[1000];
	fgets(txt1,sizeof(txt1),in);
	fgets(txt2,sizeof(txt2),in);
	int count1=0, count2=0, num1=0, num2=0;
	int i, flag=0;
       //	if (txt1[1]=='}') count1=0;
       //	else
       //	{
	for (i=0;i<strlen(txt2);i++)
	{
	    //	cout<<txt2[i];
		if (txt2[i]=='{') count2++;
	}
	for (i=0;i<strlen(txt1);i++)
	{
	    //	cout<<txt2[i];
		if (txt1[i]=='{') count1++;
	}
	while (count2!=1)
	{
		count2=count2/2;
		num2++;
	}
	while (count1!=1)
	{
		count1=count1/2;
		num1++;
	}
      //	cout<<num2;
	num1=num1+num2;
	char n[]="{}", o[]="{{}}";
	switch(num1)
	{
	case 0:
		fprintf(out,n);
		break;
	case 1:
		fprintf(out,o);
		break;
	case 2:
		fprintf(out,"{");
		fprintf(out,n);
		fprintf(out,",");
		fprintf(out,o);
		fprintf(out,"}");
		break;
	case 3:
		fprintf(out,"{");
		fprintf(out,n);
		fprintf(out,",");
		fprintf(out,o);
		fprintf(out,",");
		fprintf(out,"{");
		fprintf(out,n);
		fprintf(out,",");
		fprintf(out,o);
		fprintf(out,"}");
		fprintf(out,"}");
		break;
	case 4:
		fprintf(out,"{");
		fprintf(out,n);
		fprintf(out,",");
		fprintf(out,o);
		fprintf(out,",");
		fprintf(out,"{");
		fprintf(out,n);
		fprintf(out,",");
		fprintf(out,o);
		fprintf(out,"}");
		fprintf(out,",");
		fprintf(out,"{");
		fprintf(out,n);
		fprintf(out,",");
		fprintf(out,o);
		fprintf(out,",");
		fprintf(out,"{");
		fprintf(out,n);
		fprintf(out,",");
		fprintf(out,o);
		fprintf(out,"}");
		fprintf(out,"}");
		fprintf(out,"}");
		break;


	}
	return 0;
}
