program Project2;

function num(var s:string; k:longint):integer;
var i:longint;
    c:integer;
begin
    c:=-1;
    i:=length(s);
    while s[i]='}' do begin
      inc(c);
      dec(i);
    end;
    Result:=c;
end;

function nums(a:integer):string;
var i:integer;
    s:string;
begin
    if (a>=0) then begin
      s:='{';
      for i:=0 to a-1 do begin
        s:=s+nums(i);
        if i<a-1 then s:=s+',';
      end;
      s:=s+'}';
    end else s:='';
    Result:=s;
end;

var a, b:integer;
    s:string;
    f, g:text;

begin
    assign(f, 'input.txt');
    reset(f);
    readLn(f, s);
    a:=num(s, 1);
    readln(f, s);
    b:=num(s, 1);
    close(f);
    assign(g, 'output.txt');
    rewrite(g);
    write(g, nums(a+b));
    close(g);
end.
