program Project3;

uses
  SysUtils;

const max = 15;

Var f,g:text;
    m:array[0..max] of String;
    len:array[0..max] of Integer;
    I:Integer;
    s,s2:String;

    Function Pos(l:Word):Word;
    Var I:Word;
    Begin
      I:=0;
      while (l>len[I]) do Inc(I);
      Pos:=I;
    End;

begin
  assign(f,'.\input.txt');
  ReSet(f);
  assign(g,'.\output.txt');
  ReWrite(g);

  m[0]:='{}'; len[0]:=2;
  s:=m[0];
  for I:=1 to max do
    begin
      s:=s+','+'{'+s+'}';
      m[I]:='{'+s+'}';
      len[I]:=length(m[I]);
    end;

  readln(f,s);
  readln(f,s2);

  writeln(g,m[Pos(length(s))+Pos(length(s2))]);

  Close(g);
  Close(f);

end.
