// by googol_S0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll P[5050][5050];
int main(){
  ll M,N;
  cin>>M>>N;
  for(ll i=0;i<=N;i++)P[i][0]=1;
  for(ll i=0;i<=N;i++){
    for(ll j=0;j<M;j++){
      P[i][j+1]=P[i][j]*i%mod;
    }
  }
  ll ANS=0;
  for(ll x=1;x<=N;x++){
    ANS+=(P[N-x+1][M]-P[N-x][M]+mod);
  }
  ANS%=mod;
  for(ll r=0;r<M-1;r++){
    for(ll x=1;x<=N;x++){
      ANS+=(((P[N-x+1][r+1]-P[N-x][r+1]+mod)*(x-1)%mod)*(P[N][M-(r+2)]))%mod;
    }
    ANS%=mod;
  }
  for(ll l=1;l<M;l++){
    for(ll x=1;x<=N;x++){
      ANS+=(((P[N-x+1][M-l]-P[N-x][M-l]+mod)*(x-1)%mod)*(P[N][l-1]))%mod;
    }
    ANS%=mod;
  }
  for(ll k=1;k<M;k++){
    ll X=M-1-k;
    for(ll x=1;x<=N;x++){
      ANS+=X*(((P[N-x+1][k]-P[N-x][k]+mod)*(((x-1)*(x-1))%mod)%mod)*(P[N][M-(k+2)])%mod)%mod;
    }
    ANS%=mod;
  }
  cout<<ANS<<"\n";
}
#include <iostream>

constexpr int N = 200005;
constexpr int p = 998244353;

int add(int x, int y) { return (x += y) >= p ? x - p : x; }
int mul(int x, int y) { return (long long)x * y % p; }
int power(int x, int y) { int ans = 1; for (; y; y >>= 1) { if (y & 1) ans = mul(ans, x); x = mul(x, x); } return ans; }

int n, m;
int f[N], primes[N], powcnt[N], inv[N], cnt;
bool vis[N];

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
    std::cin >> n >> m;
    inv[1] = 1;
    for (int i = 2; i <= m; ++i) inv[i] = mul(inv[p % i], p - p / i);
    f[1] = 1;
    vis[1] = true;
    for (int i = 2; i <= m; ++i) {
        if (!vis[i]) primes[++cnt] = i, f[i] = n, powcnt[i] = 1;
        for (int j = 1; j <= cnt && i * primes[j] <= m; ++j) {
            vis[i * primes[j]] = true;
            if (!(i % primes[j])) {
                powcnt[i * primes[j]] = powcnt[i] + 1;
                f[i * primes[j]] = mul(f[i], mul(n + powcnt[i * primes[j]] - 1, inv[powcnt[i * primes[j]]]));
                break;
            } else {
                powcnt[i * primes[j]] = 1;
                f[i * primes[j]] = mul(f[i], f[primes[j]]);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= m; ++i) ans = add(ans, f[i]);
    std::cout << ans << '\n';
    return 0;
}
