#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int maxn = 1e6 + 5;
const int inf = 1e9 + 5;
const int mod = 998244353;
const int N = 3e3;
using namespace std;
int n, m;
int f[3005][3005];//f[n][k]表示用数字1,2,...,n拼成若干个长度都小于等于k的环有多少种方案(环间的顺序不重要,即两个环交换位置也是同一种方案)
int fac[maxn], inv[maxn];
int pw[3005][3005], invp[3005][3005];//pw[i][j]为i^j, invp为逆元
int qpow(int a, int b){
int res = 1;
while(b){
if(b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
void solve(){
int