import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) def matrix_multiplication_mod(A,B,p): l = len(A) m = len(B) n = len(B[0]) C = [[0]*n for _ in range(l)] for i in range(l): for j in range(n): C[i][j] = sum((A[i][k]*B[k][j]) % p for k in range(m)) % p return C def matrix_power_mod(A,n,p): l = len(A) C = [[0] * l for _ in range(l)] for i in range(l): C[i][i] = 1 while n > 0: if n % 2 == 1: C = matrix_multiplication_mod(C,A,p) A = matrix_multiplication_mod(A,A,p) n >>= 1 return C N,K = MI() mod = 998244353 A = [[0]*(K**2) for _ in range(K**2)] for j in range(K): for k in range(K): i = K*j+k if j < k: for l in range(k): if l == j: continue A[i][K*k+l] = 1 else: for l in range(k+1,K): if l == j: continue A[i][K*k+l] = 1 X = matrix_power_mod(A,N-2,mod) ans1 = 0 for i in range(K): for j in range(K): if i == j: continue for k in range(K**2): ans1 += X[K*i+j][k] ans1 %= mod ans2 = ans1*N*(K-1)*(mod+1)//2 ans2 %= mod print(ans1,ans2)