from collections import defaultdict as d a=d(int) for i in range(int(input())): s,t=map(str,input().split()) a[s]=1 a[t]=max(a[t],0) for i in a.keys(): if a[i]==0: print(i)