N, K = map(int, input().split()) mod = 998244353 """ dp[i,j]: 前2つが i, j ->何通り """ dp = [[0] * K for _ in range(K)] cnt = [[0] * K for _ in range(K)] for i in range(K): for j in range(i+1, K): dp[i][j] = 1 dp[j][i] = 1 cnt[i][j] = i + j cnt[j][i] = i + j for _ in range(N-2): ndp = [[0] * K for _ in range(K)] ncnt = [[0] * K for _ in range(K)] # i < j -> j > k for j in range(K): s = 0 c = 0 for i in range(j): s += dp[i][j] s %= mod c += cnt[i][j] c %= mod for k in range(j): ndp[j][k] += s - dp[k][j] ndp[j][k] %= mod ncnt[j][k] += c - cnt[k][j] ncnt[j][k] += (s - dp[k][j]) * k ncnt[j][k] %= mod # i > j -> j < k for j in range(K): s = 0 c = 0 for i in range(j + 1, K): s += dp[i][j] s %= mod c += cnt[i][j] for k in range(j + 1, K): ndp[j][k] += s - dp[k][j] ndp[j][k] %= mod ncnt[j][k] += c - cnt[k][j] ncnt[j][k] += (s - dp[k][j]) * k ncnt[j][k] %= mod dp = ndp cnt = ncnt ans1 = 0 ans2 = 0 for i in range(K): for j in range(K): ans1 += dp[i][j] ans1 %= mod ans2 += cnt[i][j] ans2 %= mod print(ans1, ans2)