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