#P6561. [SBCOI2020] 人

[SBCOI2020] 人

Description

In her dream, there are 2m2m memory fragments, numbered 1,2,,2m1,2,\cdots,2m, and there are aa white fragments and bb black fragments.

She vaguely remembers that she needs to choose aa white fragments from the memory fragments with odd indices to form a memory, and choose bb black fragments from the memory fragments with even indices to form a memory, and the indices of the chosen fragments are pairwise non-adjacent.

She wants to know how many ways there are to choose them. That is, choose aa odd numbers and bb even numbers from 12m1-2m, and the chosen numbers are pairwise non-adjacent.

Since the answer may be large, she only needs the result modulo 998244353998244353.

Input Format

This problem has multiple test cases.

The first line contains the number of test cases TT.

The next TT lines each contain three integers m,a,bm, a, b.

Output Format

Output TT lines, each line containing one integer representing the answer.

6
2 1 1
4 2 1
114 5 14
1919 8 10
19260 8 17
114514 1919 810
1
6
43944630
803733835
204764788
713170605

Hint

Sample Explanation

For the first query, there are 44 numbers in total. Choose one number from the odd set {1,3}\{1,3\} and one number from the even set {2,4}\{2,4\}. The only way to choose two non-adjacent numbers is 1,41,4.
For the second query, there are 88 numbers in total. Choose 22 numbers from the odd set {1,3,5,7}\{1,3,5,7\} and 11 number from the even set {2,4,6,8}\{2,4,6,8\}. The 33 chosen numbers must be pairwise non-adjacent. The valid choices are: {1,3,6}\{1,3,6\}, {1,3,8}\{1,3,8\}, {1,5,8}\{1,5,8\}, {1,4,7}\{1,4,7\}, {3,5,8}\{3,5,8\}, {2,5,7}\{2,5,7\}. There are 66 ways in total.

The ranges of the later queries are too large, so no sample explanation is provided.

Constraints

This problem uses bundled testdata, with 33 subtasks.

Subtask1(10%)Subtask 1 (10\%): 1T101 \le T \le 10, 1a,bm101 \le a,b \le m \le 10.

Subtask2(40%)Subtask 2 (40\%): 1T1061 \le T \le 10^6, 1a,bm1001 \le a,b \le m \le 100.

Subtask3(50%)Subtask 3 (50\%): 1T1061 \le T \le 10^6, 1a,bm1061 \le a,b \le m \le 10^6.

For 100%100\% of the testdata, it is guaranteed that a+bma+b \le m.

Translated by ChatGPT 5