program zadi;
 label 1;
 var ch1,ch2: string;
     c1,c2,sum,k1,k2: longint;
procedure pechat;
 var j: integer;
     pred,s: string;
 begin
  write('{');
  pred:='{}'; s:='';
  for j:=1 to sum-1 do
   begin
    s:=pred+','+'{'+pred+'}';
    pred:=s;
    if not(j=1) then
   end;
  write(s);
  write('}')
 end;
begin
 assign(input,'input.txt');
 assign(output,'output.txt');
 reset(input); rewrite(output);
 readln(ch1); readln(ch2);
 k1:=length(ch1);
 k2:=length(ch2);
 case k1 of
 2: c1:=0;
 4: c1:=1;
 9: c1:=2;
 19: c1:=3;
 39: c1:=4;
 79: c1:=5;
 159: c1:=6;
 319: c1:=7;
 638: c1:=8;
 1277: c1:=9;
 2555: c1:=10;
 5111: c1:=11;
 10223: c1:=12;
 20447: c1:=13;
 end;
 if k1=40895 then c1:=14;
 if k1=81791 then c1:=15;
 case k2 of
 2: c2:=0;
 4: c2:=1;
 9: c2:=2;
 19: c2:=3;
 39: c2:=4;
 79: c2:=5;
 159: c2:=6;
 319: c2:=7;
 638: c2:=8;
 1277: c2:=9;
 2555: c2:=10;
 5111: c2:=11;
 10223: c2:=12;
 20447: c2:=13;
 end;
 if k2=40895 then c2:=14;
 if k2=81791 then c2:=15;
 sum:=c1+c2;
 if c1=0 then begin writeln(ch2); goto 1; end;
 if c2=0 then begin writeln(ch1); goto 1; end;
 pechat;
 1:close(input); close(output);
end.