use std::io::Read; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let mut ans = std::collections::HashMap::new(); let mut check = std::collections::HashMap::new(); let mut name = Vec::new(); for _ in 0..n { let from = itr.next().unwrap(); let to = itr.next().unwrap(); let num = ans.entry(from).or_insert(0); check.entry(from).or_insert(false); check.entry(to).or_insert(false); name.push(to); *num += 1; ans.entry(to).or_insert(0); } for &i in name.iter() { if !check[i] && ans[i] == 0 { println!("{}", i); check.insert(i, true); } } }