#include using namespace std; #define MOD 998244353 #define pb push_back #define yes "Yes" #define no "No" #define ALL(x) (x).begin(), (x).end() #define int long long template bool chmax(T &x, const T &y){if (x < y) {x = y; return true;} return false;} template bool chmin(T &x, const T &y){if (x > y) {x = y; return true;} return false;} template void print(T x){cout << x << endl;} int modpow(int x, int n){ int ret = 1; while (n > 0){ if (n & 1){ ret = (ret * x) % MOD; } n >>= 1; x = (x * x) % MOD; } return ret; } int s(int x){ return x * (x + 1) / 2 % MOD; } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; cin >> N >> M; int ans = 0; for (int m = 1; m <= M; m++){ int tmp = s(m) * modpow(m, N - 1) - s(m - 1) * modpow(m - 1, N - 1); tmp %= MOD; ans = (ans + m * tmp % MOD * N) % MOD; tmp = (s(M) - s(m - 1)) * modpow(M - m + 1, N - 1) - (s(M) - s(m)) * modpow(M - m, N - 1); tmp %= MOD; ans = (ans - m * tmp % MOD * N) % MOD; } if (ans < 0) ans += MOD; print(ans); }