import List;main=interact$unlines.map snd.sort.map(\s->(length s,s)).lines