P = 998244353 N, K = map(int, input().split()) X = [[1] * (K + 1) for _ in range(K)] for i in range(K): X[i][i] = 0 Y = [[i + j for j in range(K + 1)] for i in range(K)] for i in range(K): Y[i][i] = 0 # print("X =", X) # print("Y =", Y) for _ in range(N - 2): nX = [[0] * (K + 1) for _ in range(K)] nY = [[0] * (K + 1) for _ in range(K)] nZ = [[0] * (K + 1) for _ in range(K)] for i in range(K): for j in range(i): x = X[i][j] y = Y[i][j] nX[j][j+1] += x nX[j][i] -= x nX[j][i+1] += x nY[j][j+1] += y nY[j][i] -= y nY[j][i+1] += y nZ[j][j+1] += x nZ[j][i] -= x nZ[j][i+1] += x for j in range(i+1, K): x = X[i][j] y = Y[i][j] nX[j][0] += x nX[j][j] -= x nX[j][i] -= x nX[j][i+1] += x nY[j][0] += y nY[j][j] -= y nY[j][i] -= y nY[j][i+1] += y nZ[j][0] += x nZ[j][j] -= x nZ[j][i] -= x nZ[j][i+1] += x for j in range(K): nX[j][0] %= P for k in range(1, K): nX[j][k] = (nX[j][k-1] + nX[j][k]) % P for j in range(K): nY[j][0] %= P for k in range(1, K): nY[j][k] = (nY[j][k-1] + nY[j][k]) % P for j in range(K): nZ[j][0] %= P for k in range(1, K): nZ[j][k] = (nZ[j][k-1] + nZ[j][k]) % P for j in range(K): for k in range(K): nY[j][k] = (nY[j][k] + nX[j][k] * k) % P X = nX Y = nY # print("X =", X) # print("Y =", Y) ans1 = 0 ans2 = 0 for i in range(K): for j in range(K): ans1 += X[i][j] ans2 += Y[i][j] print(ans1 % P, ans2 % P)