from copy import deepcopy MOD = 998244353 n, k = map(int, input().split()) k2 = 2 * k * k A = [[0] * k2 for _ in range(k2)] B = [0] * k2 f = lambda x, y: x * k + y for i in range(k): for j in range(i + 1, k): p = 2 * f(i, j) B[p] += 1 B[p + 1] += i + j for i2 in range(j): if i2 == i: continue for j2 in range(i2 + 1, k): if j2 == j: continue p2 = 2 * f(i2, j2) A[p2][p] += 1 A[p2 + 1][p] += i2 + j2 A[p2 + 1][p + 1] += 1 for i in range(k): for j in range(i): p = 2 * f(i, j) B[p] += 1 B[p + 1] += i + j for i2 in range(j + 1, k): if i2 == i: continue for j2 in range(i2): if j2 == j: continue p2 = 2 * f(i2, j2) A[p2][p] += 1 A[p2 + 1][p] += i2 + j2 A[p2 + 1][p + 1] += 1 A[-1][-1] = 1 t = n // 2 - 1 while t: if t & 1: C = [0] * k2 for i in range(k2): for j in range(k2): C[i] += A[i][j] * B[j] C[i] %= MOD B = C.copy() t >>= 1 C = [[0] * k2 for _ in range(k2)] for i in range(k2): for j in range(k2): for l in range(k2): C[i][j] += A[i][l] * A[l][j] C[i][j] %= MOD A = deepcopy(C) if n % 2 == 0: cnt = 0 tot = 0 for i, b in enumerate(B): if i % 2 == 0: cnt += b cnt %= MOD else: tot += b tot %= MOD print(cnt, tot) else: cnt = 0 tot = 0 for i in range(k): for j in range(k): p = 2 * f(i, j) if i < j: for l in range(j): if i != l: cnt += B[p] tot += B[p] * l + B[p + 1] else: for l in range(j + 1, k): if i != l: cnt += B[p] tot += B[p] * l + B[p + 1] cnt %= MOD tot %= MOD print(cnt, tot)