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