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