n=int(input()) l=[input().split() for _ in [0]*n] b=set() a=[] for x,y in l: b.add(x) a.append(y) r=[] for x in a: if x in b: continue r.append(x) b.add(x) print('\n'.join(r))