#include <iostream>
#include <fstream>
#include <string.h>

using namespace std;

int main()
{
	ifstream input("input.txt", ios::in);
	ofstream output("output.txt", ios::out);
	
	int int1;
	int int2;
	char str1[88400];
	char str2[88400];
	memset(str1, 0, 88400);
	memset(str2, 0, 88400);
	
	input >> str1;
	input >> str2;
	
	char **mas;

	mas = new char*[16];
	mas[0] = "{}";
	for (int i = 1; i < 16; i++)
	{
		mas[i] = new char[88400];
		memset(mas[i], 0, 88400);
		strcat(mas[i], "{");
		for (int j = 0; j < i; j++)
		{
			if (strcmp(mas[i], "{") != 0)
				strcat(mas[i], ",");
			strcat(mas[i], mas[j]);
		}
		strcat(mas[i], "}");
		
		if (strcmp(str1, mas[i]) == 0)
			int1 = i;
		if (strcmp(str2, mas[i]) == 0)
			int2 = i;
		//if (int1 > -1 && int2 > -1 && i > int1 + int2)
		//	break;
		//output << i << ": " << mas[i] << endl;
	}
	
	//cout << "int1: " << int1 << endl;
	//cout << "int2: " << int2 << endl;

	output << mas[int1 + int2];
	
	//printf("%.2f", result / cnt);
	//cout << result / cnt << endl;
	//cout.setf(ios::showpoint | ios::fixed);
	//cout.precision(2);
	//cout << (float)(result / cnt);

	//output.setf(ios::showpoint | ios::fixed);
	//output.precision(2);
	//output << result / cnt;
	//cin.get();
	return 0;
}