Counting Sequence

아직 제출이 없습니다시간 제한16초메모리 제한1024 MB

문제

We are given integers nn and cc.

A sequence a_1,a_2,,a_ma\_1, a\_2, \ldots, a\_m is good if and only if:

  • a_i>0a\_i > 0 for all 1im1 \leq i \leq m,
  • a_i+1a_i=1|a\_{i+1}-a\_i|=1 for all 1im11 \leq i \leq m-1,
  • _i=1ma_i=n\sum\_{i=1}^m a\_i=n.

For a good integer sequence a_1,a_2,,a_ma\_1, a\_2, \ldots, a\_m, let us define

f(a)=_i=1m1\[a_i>a_i+1].f(a) = \sum\_{i=1}^{m-1} \[a\_i > a\_{i+1}]\text{.}

That is, f(a)f(a) denotes the number of indices ii that satisfy a_i>a_i+1a\_i > a\_{i+1} among all 1im11 \leq i \leq m - 1. We define the weight of the sequence aa as the value of cf(a)c^{f(a)}.

Your task is to calculate the sum of the weights of all good sequences, modulo 998,244,353998\\,244\\,353.

입력

The first line contains two integers nn and cc (1n31051 \le n \le 3 \cdot 10^5, 0c<998,244,3530 \leq c < 998\\,244\\,353).

출력

Output the answer modulo 998,244,353998\\,244\\,353.

힌트

In the first example, all good sequences are as follows:

aaf(a)f(a)cf(a)c^{f(a)}
\[5]\[5]0011
\[2,3]\[2, 3]0011
\[3,2]\[3, 2]1133
\[2,1,2]\[2, 1, 2]1133

So the answer is 1+1+3+3=81 + 1 + 3 + 3 = 8.