arr = set() for _ in range(int(input())) : arr.add(input()) arr = sorted(list(arr)) arr = sorted(arr, key=len) for r in arr: print(r)