import java.io.*;
import java.util.*;

public class Main {

	Scanner in;
	PrintWriter out;

	void solve() {
		String s1 = in.next();
		String s2 = in.next();
		String arr[] = new String[16];
		arr[0] = "{}";
		arr[1] = "{{}}";
		int i1 = 0;
		int i2 = 0;
		for (int i = 2; i <= 15; i++) {
			arr[i] = "{";
			for (int j = 0; j < i - 1; j++){
				arr[i] += arr[j] + ",";
			}
			arr[i] += arr[i-1]+"}";
		}
		for (int i = 0; i <= 15; i++) {
			if (s1.equals(arr[i])) {
				i1 = i;
			}
			if (s2.equals(arr[i])) {
				i2 = i;
			}
		}
		out.println(arr[i1 + i2]);
	}

	void run() {
		try {
			in = new Scanner(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		} catch (IOException e) {
			throw new Error(e);
		}
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}

}
