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