l=dict([input().split()for _ in[0]*eval(input().replace(" ","+"))]) for i in sorted(l.keys()):print(i,l[i])