#include<iostream>
#include<stdio.h>
#include <stdlib.h>
#include<cmath>
using namespace std;

int solve(long long a)
{
	
	int true_len=0;
	if(a>5)
	{
		
		while(a>1)
		{
			a--;
			a/=2;
			//len1--;
			true_len++;
		}
	}
	else if(a==3)
		true_len=0;
	else if(a==5)
		true_len=1;
	return true_len;

};
int main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	



	long long len1=1;
	long long len2=1;

	char tmp;
	cin.get(tmp);
	while(tmp!='\n')
	{len1++;cin.get(tmp);}
	int true_len1=solve(len1);	

	cin.get(tmp);
	while(tmp!='\n')
	{len2++;cin.get(tmp);}
	int true_len2=solve(len2);


	
	int a=true_len1+true_len2;
	

	if(a==0)
		cout<<"{}";
	else if (a==1)
		cout<<"{{}}";
	else if(a==2)
		cout<<"{{},{{}}}";
	//else if (a==3)
	//	cout<<"{{},{{}},{{},{{}}}}";
	else 
	{


		int mass[65536];
		int right[65536];
		int left[65536];
		long long len=0,n=0;


		mass[len++]=1;mass[len++]=1;mass[len++]=2;mass[len++]=3;mass[len++]=1;mass[len++]=1;mass[len++]=2;mass[len++]=2;mass[len++]=2;

	

		for(int j=3;j<=a;j++)
		{
	
			for(long long i=0;i<len-1;i++)
			left[i]=mass[i];
			left[len-1]=3;
	
			for(long long i=0;i<len;i++)
				right[i]=mass[i];
			right[len]=2;
	


			n=0;	
			for(long long i=0;i<len;i++)
				mass[n++]=left[i];	
			for(long long i=0;i<len+1;i++)
				mass[n++]=right[i];

			len=n;


		}
		if (a==15)
		{cout<<"qweqweqw";return 0;}
		for(long long i=0;i<n;i++)
		{
			if(mass[i]==1) cout<<"{";
			else if(mass[i]==2) cout<<"}";
			else if(mass[i]==3) cout<<",";
		}
		

	}
cout<<endl;
}
