import Data.Maybe import Control.Arrow import Data.List (.:) = (.) . (.) eo :: [a] -> ([a], [a]) eo = f mask &&& f (tail mask) where f = catMaybes .: zipWith ($) mask = [Just, \_ -> Nothing] <> mask rodds :: [[a]] -> [[a]] rodds = concat . transpose . uncurry (<>) . (singleton *** singleton) . second (map reverse) . eo main = interact $ unwords . rodds . words