import sys
n = int(input())
i = 0
l =[]
while i<n:
s = str(input())
if len(s)>=1 and len(s)<=100:
l.append(s[-6:])
i =i+1
else:
print('字符串长度不满足')
for k in sorted(l):
print(k)

import sys
n = int(input())
i = 0
l =[]
while i<n:
s = str(input())
if len(s)>=1 and len(s)<=100:
l.append(s[-6:])
i =i+1
else:
print('字符串长度不满足')
for k in sorted(l):
print(k)