n = int(input()) ans = [[],[]] s = 0 for a in range(n): cheat, p = input().split() if p not in ans[0]: ans[0].append(p) ans[1].append(0) if cheat not in ans[0]: ans[0].append(cheat) ans[1].append(-1) else: index = ans[0].index(cheat) ans[1][index] = -1 for a in range(len(ans[1])): if ans[1][a] == 0: print(ans[0][a])