n = int(input()) a = set() b = [] for _ in range(n): aa, bb = input().split() a.add(aa) b.append(bb) for bb in list(set(b)): if bb not in a: print(bb)