# your code goes here
dict_words = {}

for _ in range(int(input())):
    word = input()
    dict_words[f'{len(word)}'] = dict_words[f'{len(word)}']+[word] if f'{len(word)}' in dict_words.keys() else [word]

for key in sorted(dict_words.keys()):
    print(*sorted(set(dict_words[key])), sep='\n')