#include using namespace std; constexpr int mod = 998244353; long long fac[200005], finv[200005], inv[200005]; void COMinit() { fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1; for (int i = 2; i < 200005; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } long long modpow(long long a,long long b) { long long ans = 1; while(b) { if(b & 1) { (ans *= a) %= mod; } (a *= a) %= mod; b /= 2; } return ans; } long long dp[2022][2022],fac1[2022][2022]; int main() { int N,M; cin >> N >> M; dp[0][0] = 1; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { dp[i+1][j] += dp[i][j]*j%mod; dp[i+1][j] %= mod; dp[i+1][j+1] += dp[i][j]; dp[i+1][j+1] %= mod; } } COMinit(); for(int i = 1; i < N; i++) { for(int j = 0; j < N; j++) { dp[N][j] += dp[i][j]*modpow(M+1,N-i)%mod*COM(N,i)%mod; dp[N][j] %= mod; } } long long sum = 0; for(int i = 1; i <= N; i++) { fac1[i][i] = M+2-i; for(int j = i+1; j <= N; j++) { fac1[i][j] = fac1[i][j-1]*(M+2-j)%mod; } } for(int i = 1; i <= N; i++) { for(int j = 1; j <= min(M+1,N); j++) { if(i <= j) { sum += dp[N][j]*COM(j,i)%mod*fac[i]%mod*((i == j)?1:fac1[i+1][j])%mod; sum %= mod; } } } cout << sum << endl; }