N = int(input()) s = set() l = [] for _ in range(N): A = input() B = input() 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)