macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } const MOD: usize = 998244353; fn pow_mod(n: usize, k: usize, m: usize) -> usize { match k { 0 => 1, _ if k % 2 == 0 => { let mut t = pow_mod(n, k / 2, m); (t * t) % m } _ => (pow_mod(n, k - 1, m) * n) % m, } } fn main(){ input! { N: usize, M: usize, } let mut p_mod = vec![0;500005]; for i in 0..M+1{ p_mod[i] = pow_mod(i,N,MOD); } let mut ans = 0; for d in 1..M{ let mut tmp = p_mod[d + 1] + 2*(MOD - p_mod[d]) + p_mod[d - 1]; tmp %= MOD; tmp = (tmp * d) % MOD; tmp = (tmp * (M - d)) % MOD; ans += tmp; ans %= MOD; } let mut n = N; n %= MOD; ans *= n; ans %= MOD; ans *= M + 1; ans %= MOD; ans *= 499122177; ans %= MOD; println!("{}",ans); }