#include <cstdio>
#include <string>

using namespace std;
char c,M[35000];
	string str[15];

/*
string r(int n)
{	string res("");
	if(n==0) return string("{}");
	res+="{";
	for(int i=0;i<n-1;i++) {res += r(i);res+=",";}
	res+=r(n-1);
	res+="}";
	//printf("%d",n);
	return res;
}
*/
int main()
{	
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);

	int i=0,N1=0,N2=0;
	while((c=getchar())!='\n') {M[i++]=c;}
	i--;
	while(M[i]=='}') {i--;N1++;}

	i=0;
	while((c=getchar())!='\n') M[i++]=c;
	i--;
	while(M[i]=='}') {i--;N2++;}
	

	int res=N1+N2-2; 

	str[0]="{}";
	str[1]="{{}}";
	str[2]="{{},{{}}}";
	for(i=3;i<=res;i++)
	{	str[i]+="{";
		for(int j=0;j<i-1;j++) {str[i] += str[j];str[i]+=",";}
		str[i]+=str[i-1];
		str[i]+="}";
	}

	string result(str[res]);
	if(res==0) printf("{}");
	else
	{printf("{{}");
	for(i=3;i<result.size();i++)
		printf("%c",result[i]);
	}
	printf("\n");
	return 0;
}