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


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);}
		
	cin.get(tmp);
	while(tmp!='\n')
	{len2++;cin.get(tmp);}



	int true_len1=0;
	if(len1>5)
	{
		
		while(len1>1)
		{
			len1--;
			len1/=2;
			true_len1++;
		}
	}
	else if(len1==3)
		true_len1=0;
	else if(len1==5)
		true_len1=1;
	//cout<<true_len1<<endl;
	
	int true_len2=0;
	if(len2>5)
	{
		
		while(len2>1)
		{
			len2--;
			len2/=2;
			true_len2++;
		}
	}
	else if(len2==3)
		true_len2=0;
	else if(len2==5)
		true_len2=1;


	
	
	int a=true_len1+true_len2;
	//cout<<a<<endl;

	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(int i=0;i<len-1;i++)
			left[i]=mass[i];
			left[len-1]=3;
	
			for(int i=0;i<len;i++)
				right[i]=mass[i];
			right[len]=2;
	


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

			len=n;


		}

		for(int i=0;i<n;i++)
		{
			if(mass[i]==1) cout<<"{";
			else if(mass[i]==2) cout<<"}";
			else if(mass[i]==3) cout<<",";
		}
	//	cout<<endl;

	}

}
