n = int(input()) s = set() l = list() for _ in range(n): a, b = input().split() s.add(a) if b not in l: l.append(b) for x in l: if x not in s: print(x)