#include <cstdio>
#include <iostream>
#include <string.h>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

char s1[100000]={0}, s2[100000]={0};
char s[17][60000]={"{}", "{{}}", 0};
int i, j, ii, jj, n, k, k1=0, k2=0;

int main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	for(i=2; i<=15; i++)
	{
		ii=0;
		s[i][ii] = '{';
		for(j=0; j<i; j++)
		{
			n = strlen(s[j]);
			for(jj=0; jj<n; jj++)
			{
				ii++;
				s[i][ii] = s[j][jj];
			}
			if(j!=i-1) s[i][++ii]=',';
			else s[i][++ii]='}';
		}
	}
	gets(s1);
	gets(s2);
	for(i=0; i<=15; i++)
	{
		if(strlen(s[i])==strlen(s1))
			k1 = i;
		if(strlen(s[i])==strlen(s2))
			k2 =  i;
	}
	k = k1 + k2;
	puts(s[k]);
	return 0;
}