#include using namespace std; #include using namespace atcoder; using mint = modint998244353; int main () { int N, Q; cin >> N >> Q; mint qsum = N; qsum = (qsum * (N + 1)) / 2; mint ans = 0; mint kai[1000020], fkai[1000020]; kai[0] = 1; for (int i = 1; i <= N; i ++) { kai[i] = kai[i - 1] * i; } fkai[N] = kai[N].inv(); for (int i = N; i ; i --) { fkai[i - 1] = fkai[i] * i; } auto comb = [&] (int n, int r) -> mint { if (n < 0 || r < 0 || n < r) return 0; return kai[n] * fkai[r] * fkai[n - r]; }; for (int d = 1; d <= N; d ++) { mint kj = kai[d] * kai[N - d] * comb(N, d - 1); ans += kj; } ans *= Q; ans *= qsum.pow(Q - 1); cout << ans.val() << endl; }