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

typedef long long ll;
#define For(i,a,b) for(ll i = a ; i <= b ; i ++)
#define FoR(i,a,b) for(ll i = a ; i >= b ; i --)
ll MAX(ll a , ll b) {
	return (a > b ? a : b);
}
ll MIN(ll a , ll b) {
	return (a < b ? a : b);
}

using namespace std;

ll N , K;
ll cnt_S(ll s) {
	ll l = MAX(1 , s - 2 * N);
	ll r = MIN(s - 2 , N);
	ll mid = s - N - 1;
	//printf ("**%lld %lld %lld " , l , mid , r);
	if (mid < l)
		return (r - l + 1) * (2 * mid + 2 * N - l - r) / 2;
	else if (mid > r)
		return (r - l + 1) * (- 2 * mid + 2 * N + l + r) / 2;
	else
		return (mid - l + 1) * (l + 2 * N - mid) / 2 + (r - mid + 1) * (-r + 2 * N + mid) / 2 - N;
}

int main() {
	cin >> N >> K;
	For (s , 3 , N * 3) {
		ll w = cnt_S(s);
		//printf ("%lld %lld %lld\n" , s , w , K);
		if (K - w <= 0) {
			For (i , 1 , N) {
				ll l = MAX(1 , s - i - N);
				ll r = MIN(N , s - i - 1);
				ll m = MAX(r - l + 1 , 0);
				//printf ("^_^%d %d %d %d\n" , s , i , m , K);
				if (K - m <= 0)
					return (printf ("%lld %lld %lld" , i , K + l - 1LL , s - i - K - l + 1LL) , 0);
				K -= m;
			}
		}
		K -= w;
	}
	return 0;
}

#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pl = pair<ll, ll>;
constexpr int MX = 5005, MOD = 998244353;

pl DP[MX][2];

int main() {
	if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
	cin.tie(0)->sync_with_stdio(0);

	int N, M; cin >> N >> M;
	ll ans = 0;
	for (int i = 1; i <= M; ++i) {
		DP[0][0] = pl(0, M-1), DP[0][1] = pl(1, 1);
		for (int j = 0; j < N-1; ++j) {
			DP[j+1][0] = pl((M-1)*DP[j][0].f+(i-1)*DP[j][1].f, (M-1)*DP[j][0].s+(i-1)*DP[j][1].s);
			DP[j+1][1] = pl(DP[j][0].f+DP[j][0].s+(M-i+1)*DP[j][1].f, DP[j][0].s+(M-i+1)*DP[j][1].s);
			DP[j+1][0].f %= MOD, DP[j+1][0].s %= MOD;
			DP[j+1][1].f %= MOD, DP[j+1][1].s %= MOD;
		}
		(ans += DP[N-1][0].f+DP[N-1][1].f) %= MOD;
	}
	cout << ans;
}
