#P3301. [SDOI2013] 方程
[SDOI2013] 方程
Description
Given the equation .
We impose restrictions on variables through : $x_{1} \le a_{1},x_{2} \le a_{2},\dots, x_{n_1} \le a_{n_1}$.
We impose restrictions on variables through : $x_{n_1+1} \ge a_{n_1+1},x_{n_1+2} \ge a_{n_1+2},\dots,x_{n_1+n_2} \ge a_{n_1+n_2}$.
Find the number of positive integer solutions of the equation under these restrictions. The answer can be large; please output it modulo .
Input Format
Multiple test cases.
The first line contains two positive integers . denotes the number of test cases in this file, and the meaning of is as described above.
For each test case, the first line contains four non-negative integers .
The second line contains positive integers, denoting . Note that if equals , this line will be empty.
Output Format
Output lines, each containing a single integer representing the answer modulo .
3 10007
3 1 1 6
3 3
3 0 0 5
3 1 1 3
3 3
3
6
0
Hint
【Sample explanation】
For the first test case, the three solutions are , , . For the second test case, the six solutions are , , , , , .

Constraints: For of the testdata, , , , and , .
Translated by ChatGPT 5
京公网安备 11011102002149号