import sys
while True:
    try:
        m=int(input())
        lst1=[]
        for i in range(0,m):
            s=input()
            lst1.append(s[len(s)-6:len(s)])
        lst1.sort()
        for a in lst1:
            print(a)
    except:
        break