-- Practice yukicoder -- author: Leonardone @ NEETSDKASU main = interact $ fst . until (null . snd) (until ((/= "treeone") . take 7 . snd) (foldl1 ((. snd) . (,) . snd) . map ((,) "") . zipWith ($) [fst, ("forest"++) . drop 7 . snd] . repeat) . until (any id.zipWith($)[null, (=="treeone")].repeat.take 7.snd) (foldl1 ((. snd) . (,) . snd) . map ((,) "") . zipWith ($) [foldl1 (++) . zipWith ($) [fst, take 1 . snd] . repeat, tail . snd] . repeat)) . (,) ""