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