n=int(input()) A=set() B=set() for _ in range(n): a,b=map(str,input().split()) A.add(a);B.add(b) for b in B: if b not in A: print(b)