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