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