import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

public class main {
	public static void main(String[] args) throws FileNotFoundException {
		Scanner in = new Scanner(new File("input.txt"));
		PrintWriter out = new PrintWriter(new File("output.txt"));
		String s1 = in.nextLine();
		String s2 = in.nextLine();
		int c[] = new int[16];
		c[0] = 2;
		int n1 = 0, n2 = 0;
		for (int n = 0;n<=15;n++) {
			if (s1.length()==c[n]) n1 = n;
			if (s2.length()==c[n]) n2 = n;
			int s = 0;
			for (int i=0;i<=n;i++) 
				s+=c[i];
			if (n<15)
			c[n+1] = s + 2 + n;
		}
		String s[] = new String[16];
		s[0] = "{}";
		for (int i=1;i<=n1+n2;i++) {
			s[i] = new String();
			for (int j=0;j<i;j++) {
				if (j!=0) s[i] = s[i]+","+s[j]; else s[i] = s[i] + s[j];
			}
			s[i] = "{" + s[i]+"}";
		}
		out.print(s[n1+n2]);
		in.close();
		out.flush();
		out.close();
	}
}