use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.parse::<$t>().unwrap()) } macro_rules! parse_inputs { ($x:expr, $t:ident) => ($x.map(|s| s.parse::<$t>().unwrap()).collect::>()) } macro_rules! print_err { ($($arg:tt)*) => ( { use std::io::Write; writeln!(&mut ::std::io::stderr(), $($arg)*).ok(); } ) } fn main() { let mut input_line = String::new(); io::stdin().read_line(&mut input_line).unwrap(); let n = parse_input!(input_line.trim(), u64); for _ in 0..n { input_line.clear(); io::stdin().read_line(&mut input_line).unwrap(); let s = input_line.trim().bytes().map(|b| b - 48).collect::>(); let mut i = s.len() - 1; let mut ans = s.clone(); // for x in &ans { // print!("{},", x); // } // println!("", ); while i > 0 { for j in 0..i { ans[j] = (ans[j] + ans[j + 1]) / 10 + (ans[j] + ans[j + 1]) % 10; } // for x in &ans { // print!("{},", x); // } // println!("", ); i -= 1; } println!("{}", ans[0]); } }