n=int(input()) AB=[list(map(str,input().split())) for _ in range(n)] cheater,allperson=[],[] for a,b in AB: cheater.append(a) if b not in allperson: allperson.append(b) nocheater=allperson for c in cheater: if c in nocheater: nocheater.remove(c) print(*nocheater,sep="\n")