import sys input = sys.stdin.readline N, K = map(int, input().split()) mod = 998244353 dp = [[0] * K for _ in range(K)] dp2 = [[0] * K for _ in range(K)] for i in range(K): for j in range(K): if i != j: dp[i][j] = 1 dp2[i][j] = i + j #print(dp) for _ in range(N - 2): newdp = [[0] * K for _ in range(K)] newdp2 = [[0] * K for _ in range(K)] for i in range(K): for j in range(i): newdp[j][j + 1] += dp[i][j] newdp[j][j + 1] %= mod newdp[j][i] -= dp[i][j] newdp[j][i] %= mod if i + 1 < K: newdp[j][i + 1] += dp[i][j] newdp[j][i + 1] %= mod newdp2[j][j + 1] += dp2[i][j] newdp2[j][j + 1] %= mod newdp2[j][i] -= dp2[i][j] newdp2[j][i] %= mod if i + 1 < K: newdp2[j][i + 1] += dp2[i][j] newdp2[j][i + 1] %= mod for j in range(i + 1, K): newdp[j][0] += dp[i][j] newdp[j][0] %= mod newdp[j][i] -= dp[i][j] newdp[j][i] %= mod if i + 1 < K: newdp[j][i + 1] += dp[i][j] newdp[j][i + 1] %= mod newdp[j][j] -= dp[i][j] newdp[j][j] %= mod newdp2[j][0] += dp2[i][j] newdp2[j][0] %= mod newdp2[j][i] -= dp2[i][j] newdp2[j][i] %= mod if i + 1 < K: newdp2[j][i + 1] += dp2[i][j] newdp2[j][i + 1] %= mod newdp2[j][j] -= dp2[i][j] newdp2[j][j] %= mod for i in range(K): for j in range(K - 1): newdp[i][j + 1] += newdp[i][j] newdp[i][j + 1] %= mod newdp2[i][j + 1] += newdp2[i][j] newdp2[i][j + 1] %= mod for i in range(K): for j in range(K): newdp2[i][j] += newdp[i][j] * j newdp2[i][j] %= mod dp = [a[: ] for a in newdp] dp2 = [a[: ] for a in newdp2] res1 = 0 for i in range(K): res1 += sum(dp[i]) res1 %= mod res2 = 0 for i in range(K): res2 += sum(dp2[i]) res2 %= mod print(res1, res2)