import sys sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 63) # md = 10**9+7 md = 998244353 n, k = LI() c = [[0]*k for _ in range(k)] t = [[0]*k for _ in range(k)] sc = [[0]*k for _ in range(k+1)] st = [[0]*k for _ in range(k+1)] pc = [[0]*k for _ in range(k)] pt = [[0]*k for _ in range(k)] psc = [[0]*k for _ in range(k+1)] pst = [[0]*k for _ in range(k+1)] for a in range(k): for b in range(k): if a == b: continue c[a][b] = 1 t[a][b] = a+b sc[a+1][b] = sc[a][b]+1 st[a+1][b] = st[a][b]+a+b for _ in range(n-2): c, t, sc, st, pc, pt, psc, pst = pc, pt, psc, pst, c, t, sc, st for a in range(k): for b in range(k): if a == b: continue if a < b: c[a][b] = psc[k][a]-psc[a+1][a]-pc[b][a] t[a][b] = pst[k][a]-pst[a+1][a]-pt[b][a]+b*c[a][b]%md else: c[a][b] = psc[a][a]-pc[b][a] t[a][b] = pst[a][a]-pt[b][a]+b*c[a][b]%md c[a][b] %= md t[a][b] %= md sc[a+1][b] = c[a][b]+sc[a][b] st[a+1][b] = t[a][b]+st[a][b] sc[a+1][b] %= md st[a+1][b] %= md x = y = 0 for a in range(k): for b in range(k): x += c[a][b] y += t[a][b] x %= md y %= md print(x, y)