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