#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int a, b, d, len;
char s[90000];

void rec(int n)
{
	putchar('{');

	if (n > 0)
		rec(0);

	for (int i = 1; i < n; i++)
	{
		putchar(',');
		rec(i);
	}

	putchar('}');
}

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

	int i, j;

	gets(s);
	len = strlen(s);

	for (i = len - 1; s[i] == '}'; i--)
		++a;

	gets(s);
	len = strlen(s);

	for (i = len - 1; s[i] == '}'; i--)
		++b;

	d = a + b - 2;
	rec(d);
	puts("");

	return 0;
}