use std::collections::{HashMap, HashSet}; fn main() { proconio::input! { n: String, m: String, } let n = n.chars().last().map(|c| c.to_digit(10).unwrap()).unwrap(); let m = m .chars() .rev() .take(2) .collect::>() .into_iter() .rev() .collect::() .parse::() .unwrap(); println!("{}", pow_mod10(n, m)); } fn pow_mod10(a:u32, b:u32) -> u32 { let mut a = a; let mut b = b; let mut res = 1; while b > 0 { if b % 2 == 1 { res = (res * a) % 10; } a = (a * a) % 10; b /= 2; } res }