use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut a: Vec<_> = s .lines() .enumerate() .map(|s| { let n: Vec = s.1.split(' ').flat_map(str::parse).collect(); (200 - n[0], n[1], b'A' + s.0 as u8) }) .collect(); a.sort(); a.iter().for_each(|(_, _, c)| println!("{}", *c as char)); }