$$F_k'(x) = F_{k-1}(x) \left(\frac{ \mathrm e^x+\mathrm e^{-x} }2\right) = F_{k-1}(x) \cosh x$$

$$F_0 = x$$

$$\frac{\partial}{\partial x} \mathcal F = 1 + t\mathcal F \cosh x$$

$$\mathcal F(x) = \mathrm e^{t\sinh x} \int_0^x \mathrm e^{-t\sinh u} \,\mathrm d u$$

$$F_k(x) = \sum\limits_{j=0}^k \frac{ (\sinh x)^{k-j} }{(k-j)!} \int_0^x \frac{(-\sinh u)^j}{j!} \,\mathrm d u$$

$$\int_0^x \mathrm e^{ju} \,\mathrm d u = \begin{cases} \frac{\mathrm e^{jx}-1}j, &j\ne 0 \\ x, &j=0 \end{cases}$$

\begin{aligned} F_k(x) &= \int_0^x G_{k-1}(\sinh u) \cosh x \,\mathrm d u \\ &= \int_0^x G_{k-1}(\sinh u) \,\mathrm d(\sinh u) \qquad \left(\frac{\,\mathrm d(\sinh u)}{\,\mathrm d u} = \cosh u\right) \\ &= \int_0^{\sinh x} G_{k-1}(v) \,\mathrm d v \\ G_k(x) &= \int_0^x G_{k-1}(v) \,\mathrm d v \end{aligned}

\begin{aligned} A'(x)(1+x^2) &= – xA(x) \\ na_n &= (1-n) a_{n-2} \end{aligned}

\begin{aligned} (n-k-1)a_{n-k-1} &= (2-n+k) a_{n-k-3} \\ (n-k-1)b_n n^{ \underline{k+1} } &= (2-n+k) b_{n-2} (n-2)^{ \underline{k+1} } \\ n(n-1)(n-k-1) b_n &= -(n-k-1)(n-k-2)^2 b_{n-2} \\ (n-k-1)[n(n-1)b_n + (n-k-2)^2 b_{n-2}] &= 0 \end{aligned}

\begin{aligned} n(n-1)b_n + (n-k-2)^2 b_{n-2} &= \frac{[n=k+1]}{(k-1)!} \\ n(n-1)b_n + [(n-2)(n-1)+(1-2k)(n-2)+k^2] b_{n-2} &= \frac{[n=k+1]}{(k-1)!} \\ k^2 x^2 B + (1-2k)x^3 B’ + x^2(1+x^2)B” &= \frac{ x^{k+1} }{(k-1)!} \\ k^2 B + (1-2k)x B’ + (1+x^2)B” &= \frac{ x^{k-1} }{(k-1)!} \end{aligned}

\begin{aligned} P'(x) &= \left(\frac{ 1+x^{-2} }2\right) B'(X) \\ P”(x) &= \left(\frac{ 1+x^{-2} }2\right)^2 B”(X) – x^{-3} B'(x) \\ \Rightarrow B'(x) &= \left(\frac2{ 1+x^{-2} }\right) P'(x) \\ B”(x) &= \left(\frac2{ 1+x^{-2} }\right)^2 P”(x) + x^{-3}\left(\frac2{ 1+x^{-2} }\right)^3 P'(x) \end{aligned}

$$k^2 (1+x^2) P(x) + ((1+2k)x + (1-2k)x^3) P'(x) + ( x^2+x^4) P”(x) = \frac{X^{k-1}}{(k-1)!} \cdot (1+x^2)$$

$$(n+k)^2 g_n + (n-k-2)^2 g_{n-2} = 0$$

$$(n+k)^2 f_n + (n-k-2)^2 f_{n-2} + 2(n+k)g_n + 2(n-k-2)g_{n-2} = [x^n] \frac{X^{k-1}}{(k-1)!} (1+x^2)$$

\begin{aligned} f_k &= \frac 1{2^k}\sum_{j=1}^k \frac{(-1)^j}{(k-j)!j!\cdot j} \\ g_k & = \frac 1{2^kk!} \end{aligned}

#include <cstdio>
#include <cstring>
using namespace std;
const int K = 1e7 + 2;
const int mod = 998244353;
const int inv2 = 499122177;
inline int fpow(int a,int b)
{
int ret = 1;
for(;b;b >>= 1)
(b & 1) && (ret = (long long)ret * a % mod),a = (long long)a * a % mod;
return ret;
}
int k;
long long n;
int fac[K + 5],ifac[K + 5],inv[K + 5];
int vis[K + 5],cnt,prime[K + 5],pw[K + 5];
int f[K + 5],g[K + 5],ans;
int main()
{
scanf("%d%lld",&k,&n),--k;
fac[0] = 1;
for(register int i = 1;i <= k;++i)
fac[i] = (long long)fac[i - 1] * i % mod;
ifac[k] = fpow(fac[k],mod - 2);
for(register int i = k;i;--i)
ifac[i - 1] = (long long)ifac[i] * i % mod;
for(register int i = 1;i <= k;++i)
inv[i] = (long long)ifac[i] * fac[i - 1] % mod;
pw[0] = n == 1 ? 1 : 0,pw[1] = 1;
for(register int i = 2;i <= k;++i)
{
if(!vis[i])
pw[prime[++cnt] = i] = fpow(i,(n - 1) % (mod - 1));
for(register int j = 1;j <= cnt && i * prime[j] <= k;++j)
{
vis[i * prime[j]] = 1,pw[i * prime[j]] = (long long)pw[i] * pw[prime[j]] % mod;
if(!(i % prime[j]))
break;
}
}
n %= mod;
f[k] = (long long)ifac[k] * fpow(2,mod - 1 - k) % mod;
for(register int i = k - 2;i >= 0;i -= 2)
f[i] = f[i + 2] * (mod - (long long)(i + 2 + k) * (i + 2 + k) % mod) % mod * inv[k - i] % mod * inv[k - i] % mod;
for(register int i = k;i > 0;i -= 2)
ans = (ans + (long long)f[i] * pw[i] % mod * n) % mod;
ans = (ans + (long long)f[0] * pw[0] % mod * n % mod * inv2) % mod;
int t = fpow(2,mod - k);
for(register int i = 0;2 * i <= k - 1;++i)
g[k - 1 - 2 * i] = (long long)(i & 1 ? mod - t : t) * ifac[i] % mod * ifac[k - 1 - i] % mod;
for(register int i = k + 1;i >= 2;i -= 2)
g[i] = (g[i] + g[i - 2]) % mod;
for(register int i = 2;i <= k + 2;++i)
g[i] = (g[i] + (long long)(mod - f[i - 2]) * (mod + 2 * (i - k - 2)) + (long long)(mod - f[i]) * (2 * (i + k))) % mod;
f[k] = 0;
for(register int i = 1;i <= k;++i)
f[k] = (f[k] + (long long)(i & 1 ? mod - inv[i] : inv[i]) * ifac[i] % mod * ifac[k - i]) % mod;
f[k] = (long long)f[k] * fpow(2,mod - 1 - k) % mod;
for(register int i = k - 1;i >= 0;--i)
f[i] = (f[i + 2] * (mod - (long long)(i + 2 + k) * (i + 2 + k) % mod) + g[i + 2]) % mod * inv[k - i] % mod * inv[k - i] % mod;
for(register int i = 1;i <= k;++i)
ans = (ans + (long long)f[i] * pw[i] % mod * i) % mod;
ans = 2 * ans % mod;
printf("%d\n",ans);
}