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