N = int(input()) B = [] A = [] for _ in range(N): b,a = input().split() B.append(b) A.append(a) for b in B: if b in A: A.remove(b) A = list(set(A)) for a in A: print(a)