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