import Data.Tree (Tree(..), flatten)






list :: Tree [Int]
list =
  Node
    []
    [ Node [] [Node [1] []]
    , Node [2] []
    , Node [] [Node [] [Node [3] [], Node [4] []], Node [5] []]
    , Node [] [Node [] [Node [] []]]
    , Node [] [Node [] [Node [6] []]]
    , Node [7] []
    , Node [8] []
    , Node [] []
    ]

flattenList :: Tree [a] -> [a]
flattenList = concat . flatten

main :: IO ()
main = print $ flattenList list