q x y=[y,x:y] f[]="0";f x='{':foldr1(#)x++"}";a#b=a++", "++b h x=f x:h(map f$foldr((=<<).q)[[]]x) main=readLn>>=putStr.(h[]!!)