#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 result(r(res));
	for(i=0;i<result.size();i++)
		printf("%c",result[i]);

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