fn solve(scanner: &mut Scanner) { let n: usize = scanner.next(); if n == 0 { println!("2"); return; } let ans = [2, 5, 6, 5, 6, 7, 0, 1, 0, 1][(n - 1) % 10]; println!("{}", ans); } fn main() { let mut scanner = Scanner::new(); let t: usize = scanner.next(); for _ in 0..t { solve(&mut scanner); } } struct Scanner { buf: Vec, } impl Scanner { fn new() -> Self { Self { buf: vec![] } } fn next(&mut self) -> T { loop { if let Some(x) = self.buf.pop() { return x.parse().ok().expect(""); } let mut source = String::new(); std::io::stdin().read_line(&mut source).expect(""); self.buf = Self::split(source); } } fn split(source: String) -> Vec { source .split_whitespace() .rev() .map(String::from) .collect::>() } }