if __name__ == '__main__': A = [] B = [] n = int(input()) for i in range(n): a, b = input().split(' ') A.append(a) B.append(b) for b in B: if b not in A: print(b)