#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define int long long
#define FOR(i,a,b,c) for(int i=a;i<b;i+=c)
#define REV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define all(x) x.begin(),x.end()                   
#define Dhruv main

const int pinf=LLONG_MAX;
const int ninf=LLONG_MIN;
const int mod=1000000007;

using namespace std;
using namespace __gnu_pbds;

typedef tree
<int,null_type,less <int>,rb_tree_tag,tree_order_statistics_node_update>
indexed_set;

typedef tree
<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>
indexed_multiset;

template <typename T>
istream & operator>>(istream &is, vector<T> &v) {
    for(auto &data:v){
    	is>>data;
    }	
    return is;
}

template <typename T>
ostream & operator<<(ostream &os,const vector<T> &v) {
    for(auto &data:v){
    	os<<data<< " ";
    }	
    return os;
}
	

int32_t Dhruv(){
	
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int T=1;

	while(T--){
		  int n;
		  cin>>n;
		  vector <int> a(n);
		  cin>>a;
		  vector <int> b(n);
		  cin>>b;
		  cout<<a[0]*b[0]<< "\n";

		  vector <int> p(n);
		  p[0]=a[0];
		  FOR(i,1,n,1) p[i]=max(p[i-1],a[i]);
		  vector <int> c(n);
		  c[0]=a[0]*b[0];
		  FOR(i,1,n,1){

		    c[i]=max(c[i-1],p[i]*b[i]);

		    cout<<c[i]<< "\n";
		  }	
		 
	}	

	#ifdef LOCAL
    	cout<< "Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<< "s\n";
    #endif                                                   
    

    return 0;

}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const long long modd = 998244353;
const int N = 5000;

long long mp[N + 5][N + 5];
long long su[N + 5][N + 5];
long long n, m;

void init()
{
	su[0][0] = 1;
	for (long long j = 1; j <= m; ++j)
	{
		mp[j][0] = 1;
		su[j][0] = (su[j - 1][0] + 1) % modd;
		for (long long i = 1; i <= n; ++i)
		{
			mp[j][i] = mp[j][i - 1] * j % modd;
			su[j][i] = (su[j - 1][i] + mp[j][i]) % modd;
		}
	}
}

int main()
{
	scanf("%lld%lld", &n, &m);
	init();
	long long ans = mp[m][n] * n % modd;
	for (int i = 2; i <= n; ++i)
	{
		for (int j = 1; j < i; ++j)
		{
			ans -= su[m - 1][i - j - 1] * mp[m][n - i + j - 1] % modd;
			ans = (ans + modd) % modd;
		}
	}
	printf("%lld", ans);
	return 0;
}
