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

public class Main {
	Scanner in;
	PrintWriter out;

	void solve(){
		String s1=in.nextLine();
		String s2=in.nextLine();
		int k=0;
		for(int i=0; i<s1.length(); i++){
			if(s1.charAt(i)==','){
				k++;
			}
		}
		int z=0;
		while(z<k){
			z*=2;
			z++;
		}
		int k1=z;
		k=0;
		for(int i=0; i<s2.length(); i++){
			if(s2.charAt(i)==','){
				k++;
			}
		}
		z=0;
		while(z<k){
			z*=2;
			z++;
		}
		int k2=z;
		if(!s1.equals("{}")){
			k1++;
		}
		if(!s2.equals("{}")){
			k2++;
		}
//		out.println(k2 + " " + k);
		int zz=k1+k2;
//		out.println(zz);
		String s="{{}}";
		if(zz==1){
			out.println("{{}}");
			return;
		}else if(zz==0){
			out.println("{}");
			return;
		}/*else if (zz==15){
			out.println(sss1+sss2);
			return;
		}*/
		for(int i=2; i<=zz; i++){
			String ss="{";
			ss+=s.substring(1, s.length()-1);
			ss+=",";
			ss+=s;
			ss+="}";
			s=ss;
		}
//		out.println(s.length());
//		out.println(s.substring(0, 40000));
//		out.println(s.substring(40000));
		out.println(s);
	}
	
	void run(){
		try {
			in=new Scanner(new FileReader("input.txt"));
			out=new PrintWriter("output.txt");
		}catch (Exception e) {
			throw new Error();
		}
		solve();
		out.close();
	}
	
	public static void main(String args[]){
		new Main().run();
	}
}
