N = int(input()) s = set() l = [] for _ in range(N): A,B = input().split() s.add(A) l.append(B) d = set() for B in l: if B not in s: if B not in d: print(B) d.add(B)