# coding: utf-8 # Your code here! N=int(input()) org=[] dic={} for _ in range(N): A,B=input().split() org.append(B) if A in dic: dic[A][0]+=1 else: dic[A]=[1,0] if B in dic: dic[B][1]+=1 else: dic[B]=[0,1] for k in dic: if dic[k][0]==0: print(k)