King of Rats

Time limit: 2s Memory limit: 512MB Input: Output:

Nous vivrons. Et nous guérirons. Les cicatrices... Nous les gardons. Pour ne pas oublier.

After an overwhelming battle against the rats, it is time for Amicia and Hugo to flee from the army of Count Victor de Arles. The soldiers have positioned themselves on a narrow path, which can be represented as a matrix of dimensions 2n2 \cdot n. Furthermore, we know that there are a total of kk soldiers on this path.

Task

Amicia and Hugo define the danger of a configuration as the number of soldier groups in it. More formally, if we consider a 2×n2 \times n binary matrix, where we have 11 in the positions where a soldier exists. We say that two cells are connected if they both have value 11 and they share an edge. Note that this relation is transitive, meaning that if two cells aa and bb are connected and cells bb and cc are connected, than aa and cc are also considered connected. A connected component is a maximal subset of connected cells with value 11. The danger is the number of connected components in this matrix.

Your task is to help the two protagonists find the expected value of the danger, considering all possible configurations. Each configuration is considered equiprobable. In this case, the expected value can be defined as the average number of connected components across all possible configurations.

Implementation

You have to implement the following functions:

void prec(int subtask_id)
int solve(int n, int k)

The first function will be called once at the beginning of the grader. You can use it for preprocessing.

The second function should return the expected danger, given the nn and kk parameters, modulo 998 244 353998 \ 244 \ 353. Formally, let M=998 244 353M = 998 \ 244 \ 353. It can be shown that the answer can be expressed as an irreducible fraction pq\frac{p}{q}, where pp and qq are integers and q≢0(modM)q \not\equiv 0 \pmod{M}. Return the integer equal to pq1(modM)p \cdot q^{-1} \pmod{M}. In other words, return such an integer xx that 0x<M0 \leq x < M and xqp(modM)x \cdot q \equiv p \pmod{M}.

The second function will be called tt times. This means there are multiple testcases in the input!

Do not forget to include the header file "kor.h", otherwise you will get compile error!

Constraints

  • 1t101 \leq t \leq 10
  • 1n1091 \leq n \leq 10^9
  • 0k1060 \leq k \leq 10^6
  • k2nk \leq 2 \cdot n
# Points Constraints
1 10 1n1001 \leq n \leq 100
2 5 1n2 0001 \leq n \leq 2 \ 000
3 5 k3k \leq 3
4 15 k40k \leq 40
5 10 k400k \leq 400
6 15 k2 000k \leq 2 \ 000
7 40 No additional constraints.

Example 1

input

2
6
2 2
5 10
2000 3
2000 5
100 32
150 278

output

332748119
1
518205646
742082393
368118258
937239298

Explanation

Note that the grader should be provided with the subtask of the test, the number of testcases tt and the values n,kn, k for each testcase.

For the first testcase of the first sample, the possible configurations are shown below:

There is a total of 66 configurations, 44 of which have a single component. The answer is thus 41+226=43\frac{4 \cdot 1 + 2 \cdot 2}{6} = \frac{4}{3}

Example 2

input

7
8
100000000 0
100000000 1
100000000 2
100000000 3
5219873 192
853875838 238
43782384 1500
58123292 180000

output

0
1
268791198
806373591
782159797
435727907
712321002
257644694

Log in or sign up to be able to send submissions!