l={} for i in open(0).readlines()[1:]: k,v=i.split() l[k]=v for i in sorted(l.keys()): print(i,l[i])