program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var a,b,res:string;
k,e,r,t,y,lol,olo,i,q,w,q1,w1,sign:integer;
fu,sh:real;
begin
  assign(input,'input.txt');
  reset(input);
  assign(output,'output.txt');
  rewrite(output);
  readln(a);
  readln(b);
  sign:=0;
  if a='{}' then q:=0;
  if a='{{}}' then q:=1;
  if b='{}' then w:=0;
  if b='{{}}' then w:=1;
  k:=1;
  t:=0;
  y:=0;
  while k>0 do begin
  e:=pos('},{',a);
  if e>0 then begin
  delete(a,1,e+1);
  t:=t+1; end else k:=0;
  end;
  k:=1;
  while k>0 do begin
  r:=pos('},{',b);
  if r>0 then begin
  delete(b,1,r+1);
  y:=y+1; end else k:=0;
  end;
  lol:=1;
  olo:=1;
  fu:=t+1;
  sh:=y+1;
  if (t<>0) then begin
  while fu>1 do
  begin
    fu:=fu/2;
    lol:=lol+1;
  end; end;
  if (y<>0) then begin
  while sh>1 do
  begin
    sh:=sh/2;
    olo:=olo+1;
  end; end;
  if lol>1 then q:=lol;
  if olo>1 then w:=olo;

  res:='{{}}';
  if (q+w>1) then  begin
  for i:=2 to (q+w) do
  begin
    delete(res,length(res),1);
    res:=res+','+res+'}}';
    sign:=1
  end;  end;
  if (q+w=1) then writeln('{{}}');
  if (q+w=0) then writeln('{}');
  if sign=1 then
  writeln(res);

end.
