n = int(input()) a = [] b = [] for _ in range(n): aa, bb = input().split() a.append(aa) b.append(bb) for i, bb in enumerate(b): if bb in a: del b[i] for v in b: print(v)