#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[1000];
	char str2[1000];
	memset(str1, 0, 1000);
	memset(str2, 0, 1000);
	
	input >> str1;
	input >> str2;
	
	char **mas;

	mas = new char*[15];
	mas[0] = "{}";
	for (int i = 1; i < 15; i++)
	{
		mas[i] = new char[100000];
		memset(mas[i], 0, 100000);
		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;
		//cout << 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;
}