fn main() { let mut xx = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok(); let xx: Vec<&str> = xx.split_whitespace().skip(1).collect(); let table: Vec = (0..=9).chain(1..=9).collect(); let conv = |c: char| c.to_digit(10).unwrap() as usize; for &x in &xx { let mut x: Vec = x.chars().map(conv).collect(); while x.len() > 1 { x = x.windows(2).map(|x| table[x[0] + x[1]]).collect(); } println!("{}", x[0]); } }