#include <stdio.h>
#include <string.h>
int A=0, B=0, i = 0;
char str0[30], str1[50], str2[90], str3[200], operandA[200], operandB[200];

int main()
{
	freopen ("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	sprintf(str0, "{}");
	sprintf(str1, "{{}}");
	sprintf(str2, "{{},{{}}}");
	sprintf(str3, "{{},{{}},{{},{{{}}}}");
	scanf ("%s", &operandA);
	scanf ("%s", &operandB);
	if (strcmp (operandA, str0) == 0)
		A = 0; 
	if (strcmp (operandA, str1) == 0)
		A = 1; 
	if (strcmp (operandA, str2) == 0)
		A = 2; 
	if (strcmp (operandB, str3) == 0)
		A = 3; 
	if (strcmp (operandB, str0) == 0)
		B = 0; 
	if (strcmp (operandB, str1) == 0)
		B = 1; 
	if (strcmp (operandB, str2) == 0)
		B = 2; 
	if (strcmp (operandB, str3) == 0)
		B = 3; 
	if ((A+B) == 0)
		printf("%s", str0);
	if ((A+B) == 1)
		printf("%s", str1);
	if ((A+B) == 2)
		printf("%s", str2);
	if ((A+B) == 3)
		printf("%s", str3); 
	return 0;
}
