N = int(input()) B = set() A = [] for i in range(N): b,a = input().split() B.add(b) if not a in A: A.append(a) for a in A: if a not in B: print(a)