use proconio::{fastout, input}; 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); }