#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) using mll = atcoder::modint998244353; void testcase(){ ull N,M; cin >> N >> M; mll ans = 0; for(ull minA = 1; minA <= M; minA++){ mll w = M - minA + 1; mll x = mll(M*(M+1)/2 - (minA-1)*minA/2) / w; ans -= w.pow(N) * x * N; } ans += mll(M).pow(N) * (M*(M+1)/2) * N; for(ull maxA = 1; maxA < M; maxA++){ mll w = maxA; mll x = mll(maxA*(maxA+1)/2) / w; ans -= w.pow(N) * x * N; } cout << ans.val() << "\n"; } int main(){ testcase(); return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;