def main(): N = int(input()) students = set() cheeters = set() others = [] for i in range(N): A, B = input().split() cheeters.add(A) others.append(B) students.add(A) students.add(B) honests = students ^ cheeters ans = [] for name in others: if name in honests: if not name in ans: ans.append(name) for a in ans: print(a) if __name__ == "__main__": main()