N, *SD = open(0).read().split() for s, d in sorted(zip(*[iter(SD)] * 2)): print(s, d)