N = int(input()) AB = [tuple(input().split()) for _ in range(N)] s = set() for Ai, _ in AB: s.add(Ai) checked = set() for _, Bi in AB: if Bi not in s and Bi not in checked: checked.add(Bi) print(Bi)