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 s: &str = s.trim(); let mut idx: usize = 0; let mut length: usize = 0; let mut tempidx: usize = 0; let mut templength: usize = 0; s.chars().enumerate().for_each(|pair| { let i = pair.0; let temp = (pair.1).to_string().parse::(); if temp.is_ok() { if templength == 0 { tempidx = i; } templength += 1; if length <= templength { idx = tempidx; length = templength; } } else { templength = 0; } }); if length == 0 { println!("{}", s); } else { let temp = (&s[idx..idx+length]).parse::().unwrap() + 1; let temp = if temp.to_string().len() < length { format!("{:01$}", temp, length) } else { temp.to_string() }; println!("{}{}{}", &s[0..idx], temp, &s[idx+length..s.len()]); } } }