# 2020/01/06 n=int(input()) aa=[] bb=[] for i in range(n): a,b=input().split() aa.append(a) bb.append(b) res=set(bb)-set(aa) for b in bb: if b in res: print(b)