import Data.List import Data.Function main = getLine >>= mapM_ print . groupBy ((==) `on` sort) . sortBy (compare `on` sort) . words