local mod = 998244353 local mfl = math.floor local function bmul(x, y) local x0, y0 = x % 31596, y % 31596 local x1, y1 = mfl(x / 31596), mfl(y / 31596) return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod end local function badd(x, y) return (x + y) % mod end local function bsub(x, y) return x < y and x - y + mod or x - y end local n, k = io.read("*n", "*n") local dp1, dp2 = {}, {} local dpsum1, dpsum2 = {}, {} for i = 1, k do dp1[i] = {} dp2[i] = {} dpsum1[i] = {} dpsum2[i] = {} end for i = 1, k do for j = 1, i - 1 do dp1[i][j] = 1 dpsum1[i][j] = i + j - 2 end dp1[i][i] = 0 dpsum1[i][i] = 0 for j = i + 1, k do dp1[i][j] = 1 dpsum1[i][j] = i + j - 2 end end for irep = 3, n do local src = irep % 2 == 1 and dp1 or dp2 local dst = irep % 2 == 1 and dp2 or dp1 local srcsum = irep % 2 == 1 and dpsum1 or dpsum2 local dstsum = irep % 2 == 1 and dpsum2 or dpsum1 for i = 1, k do for j = 1, k do dst[i][j] = 0 dstsum[i][j] = 0 end end for i = 1, k do for j = 1, i - 1 do local sij = src[i][j] local dj = dst[j] dj[j + 1] = badd(dj[j + 1], sij) dj[i] = bsub(dj[i], sij) if i < k then dj[i + 1] = badd(dj[i + 1], sij) end sij = srcsum[i][j] dj = dstsum[j] dj[j + 1] = badd(dj[j + 1], sij) dj[i] = bsub(dj[i], sij) if i < k then dj[i + 1] = badd(dj[i + 1], sij) end end for j = i + 1, k do local sij = src[i][j] local dj = dst[j] dj[1] = badd(dj[1], sij) dj[j] = bsub(dj[j], sij) dj[i] = bsub(dj[i], sij) dj[i + 1] = badd(dj[i + 1], sij) sij = srcsum[i][j] dj = dstsum[j] dj[1] = badd(dj[1], sij) dj[j] = bsub(dj[j], sij) dj[i] = bsub(dj[i], sij) dj[i + 1] = badd(dj[i + 1], sij) end end for i = 1, k do local di = dst[i] local dsi = dstsum[i] for j = 2, k do di[j] = badd(di[j], di[j - 1]) dsi[j] = badd(dsi[j], dsi[j - 1]) end for j = 2, k do dsi[j] = badd(dsi[j], bmul(j - 1, di[j])) end end end local tbl = n % 2 == 1 and dp2 or dp1 local tblsum = n % 2 == 1 and dpsum2 or dpsum1 local ret = 0 local retsum = 0 for i = 1, k do for j = 1, k do ret = badd(ret, tbl[i][j]) retsum = badd(retsum, tblsum[i][j]) end end print(ret .. " " .. retsum)