#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { int N, K; scanf("%d %d", &N, &K); // dp[i][j][k] i番目がj, i+1番目がkの門松列の数 vector>> dp(N - 1, vector>(K, vector(K))); vector>> dp2(N - 1, vector>(K, vector(K))); rep(i, K) rep(j, K) { if (i != j) dp[0][i][j] = 1; if (i != j) dp2[0][i][j] = i + j; } ll MOD = 998244353; rep(i, N - 2) { rep(j, K) { rep(k, K) { if (j < k) { rep(l, k) { if (l == j) continue; dp[i + 1][k][l] += dp[i][j][k]; dp[i + 1][k][l] %= MOD; dp2[i + 1][k][l] += dp2[i][j][k] + l * dp[i][j][k]; dp2[i + 1][k][l] %= MOD; } } if (j > k) { for (int l = k + 1; l < K; l++) { if (l == j) continue; dp[i + 1][k][l] += dp[i][j][k]; dp[i + 1][k][l] %= MOD; dp2[i + 1][k][l] += dp2[i][j][k] + l * dp[i][j][k]; dp2[i + 1][k][l] %= MOD; } } } } } ll ans1 = 0, ans2 = 0; rep(j, K) rep(k, K) { ans1 = (ans1 + dp[N - 2][j][k]) % MOD; ans2 = (ans2 + dp2[N - 2][j][k]) % MOD; } printf("%lld %lld\n", ans1, ans2); }