n = int(input()) words = [input() for word in range(n)] words = list(set(words)) words.sort(key=lambda x: (len(x),x)) for w in words: print(w)