#include using namespace std; #define int long long const int N = 4e5 + 10; const int mod = 998244353; int n, k; int f[N]; int qmi(int a, int k) { int res = 1; a = a % mod; while (k) { if (k & 1) res = res * a % mod; k >>= 1; a = a * a % mod; } return res; } signed main() { cin >> n >> k; int res = 0; for (int i = k; i >= 1; i--) { f[i] = qmi(k, n); int a = (k - i + 1) * n % mod * qmi(i - 1, n - 1) % mod; int b = qmi(i - 1, n) % mod; f[i] = (f[i] - a + mod - b + mod) % mod; res = res + ((f[i] - f[i + 1] + mod) * i) % mod; res %= mod; } cout << res << endl; }