<reponame>GSri30/Competetive_programming<filename>HackerEarth/Hashing/Frequency_Of_Students.py
# Write your code here
n = int(input())
dict = {}
while n > 0 :
    name = input()
    if name in dict :
        dict[name] += 1
    else :
        dict[name] = 1
    n -= 1
for key,value in sorted(dict.items()) :
    print(key,value)

# Write your code here
n = int(input())
dict = {}
while n > 0 :
    name = input()
    if name in dict :
        dict[name] += 1
    else :
        dict[name] = 1
    n -= 1
for key,value in sorted(dict.items()) :
    print(key,value)
# Write your code here