#include <cstdio>
#include <string>
using namespace std;
char c,M[35000];
/*
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; 
	string str[17];
	str[0]="{}";
	for(i=1;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]);
	for(i=0;i<result.size();i++)
		printf("%c",result[i]);

	printf("\n");
	return 0;
}