Python
import sys
n = int(input())
array = []
for _ in range(n):
array.append(sys.stdin.readline().rstrip())
array = list(set(array))
array.sort(key= lambda x: (len(x), x))
for string in array:
print(string)
import sys
n = int(input())
array = []
for _ in range(n):
array.append(sys.stdin.readline().rstrip())
array = list(set(array))
array.sort(key= lambda x: (len(x), x))
for string in array:
print(string)