n=int(input()) cheater,person=[],[] for _ in range(n): a,b=input().split() cheater.append(a) person.append(b) nocheater=set(person)-set(cheater) nocheater=sorted(set(nocheater),key=person.index) print(*nocheater,sep="\n")