N, K = map(int, input().split()) mod = 998244353 def mat_mul(A, B): res = [[0] * len(B[0]) for _ in range(len(A))] for i in range(len(A)): for k in range(len(A[0])): for j in range(len(B[0])): res[i][j] += A[i][k] * B[k][j] res[i][j] %= mod return res def mat_pow(A, n): size = len(A) res = [[0] * size for _ in range(size)] for i in range(size): res[i][i] = 1 while n: if n & 1: res = mat_mul(res, A) A = mat_mul(A, A) n >>= 1 return res A = [[0]*(K*K) for _ in range(K*K)] B = [0] * (K*K) for x in range(K): for y in range(K): if x == y: continue if x < y: for z in range(y): if x != z: A[x*K+y][y*K+z] = 1 if x > y: for z in range(y+1, K): if x != z: A[x*K+y][y*K+z] = 1 B[x*K+y] = 1 P = mat_pow(A, N-2) ans1 = 0 for i in range(K*K): for j in range(K*K): ans1 += P[i][j] * B[j] % mod ans1 %= mod ans2 = ans1 * N * (K - 1) * pow(2, mod-2, mod) % mod print(ans1, ans2)