#include #include #include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) using m32 = atcoder::modint998244353; int main(){ m32 ans = 0; int N, K; cin >> N >> K; for(int max2=1; max2<=K; max2++){ m32 tmp = 0; tmp += m32(max2-1) * m32(K-max2+1).pow(N-1) * N; tmp -= m32(max2-1) * m32(K-max2).pow(N-1) * N; ans += tmp * max2; } for(int max2=1; max2<=K; max2++){ m32 tmp = 0; tmp += m32(K-max2+1).pow(N); tmp -= m32(K-max2).pow(N-1) * N; tmp -= m32(K-max2).pow(N); ans += tmp * max2; } ans = m32(K).pow(N) * (K+1) - ans; cout << ans.val() << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;