fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); for _ in 0..t { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut s: Vec = s.trim().chars().collect(); s.reverse(); let mut flg = false; let mut flg2 = false; let mut result = s.iter() .map(|c| { if flg && flg2 { return c.to_string(); } let temp = c.to_string().parse::(); if temp.is_ok() { let temp = temp.unwrap(); flg = true; if !flg2 { if temp == 9 { return "0".to_string(); } else { flg2 = true; return (temp + 1).to_string(); } } else { return c.to_string(); } } else { if flg && !flg2 { flg2 = true; return format!("{}{}", c, 1); } else { return c.to_string(); } } }) .collect::>() ; result.reverse(); println!("{}{}",if flg && !flg2 { "1" } else { "" }, result.join("")); } }