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