var i,j,a1,a2,n,t:longint;
m1,m2:array [1..2000] of longint;
inp,out:text; c:char; s,s1,s2,s3:string;
ms:array [1..170] of string;
begin
s1:='{'; s2:='}'; s:=',';
assign(inp,'Input.txt'); reset(inp);
assign(out,'output.txt');rewrite(out);
m1[1]:=2;
m1[2]:=4;
for i:=3 to 15 do  begin
m1[i]:=m1[i-1]*2+1;
writeln(m1[i]);
end;
while not eoln(inp) do begin
read(inp,c); t:=t+1;
end; m2[1]:=t;
t:=0;
readln(inp);
while not eoln(inp) do begin
read(inp,c); t:=t+1;
end; m2[2]:=t;
writeln(m2[1],' ',m2[2]);
for i:=1 to 15 do begin
if m2[1]=m1[i] then a1:=a1+i;
if m2[2]=m1[i] then a1:=a1+i;
end;
ms[1]:=s1+s2;
ms[2]:='{{}}';
for i:=2 to 15 do begin
ms[i]:=s1;
for j:=1 to i-1 do begin
if j<>i-1 then
ms[i]:=ms[i]+ms[j]+s else
ms[i]:=ms[i]+ms[j];
end;
ms[i]:=ms[i]+s2;
end;
write(a1);
write(out,ms[a1-1]);
close(inp);
close(out);
end.