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