n=int(input()) a=[] b=[] for _ in [0]*n: i,j=input().split() a+=[j] b+=[i] for x in a: if x not in b: print(x) b+=[x]