f [] is _ ks _ = ([],ks) f ('(':s) is j ks n = f s (j:is) (j+1) ks (n+1) f (')':s) (i:is) j ks n = (c++i:a,d) where (a,b) = f s is (j+1) (j:ks) 0 (c,d) = splitAt n b main = do getLine s <- getLine mapM_ print $ fst $ f s [] 1 [] 0