#P5272. 总而言之神J要去练习篮球
总而言之神J要去练习篮球
Description
To prevent God J from using a basketball to create a pointer and point himself out, Lord God Tree forces God J to use basketballs to build a matrix.
This matrix is infinite. Rows and columns are indexed starting from 0, and .

Now, for a submatrix with top-left corner and bottom-right corner , we randomly select a matrix from it times . Ask for the probability that all selected matrices are exactly the same, modulo .
Input Format
The first line contains an integer , meaning there are queries.
Then lines follow, each containing 7 integers .
Output Format
Output the answer modulo . It is guaranteed that the answer exists.
5
54 63 5 59 5 27 2
33 42 1 29 9 23 2
54 55 56 57 2 1 3
40 64 17 40 19 9 1
54 65 35 50 3 10 3
626436786
71428572
250000002
1
154489797
3
1 2 1 2 1 1 2
3 100 39 100 1 1 2
48395 309846 34098 234095 1 1 2
500000004
779746001
262016540
Hint
For the query 1 2 1 2 1 1 2:

The matrices that can be selected are: 0 and 3, each appearing twice.
There are the following cases:
First pick 3, second pick 0, a total of 4 ways.
First pick 3, second pick 3, a total of 4 ways.
First pick 0, second pick 0, a total of 4 ways.
First pick 0, second pick 3, a total of 4 ways.
There are 16 ways in total, and the valid ones are ways.
So the answer is .
Constraints
For all testdata, $0\leq lx\leq rx\leq 10^9,0\leq ly\leq ry\leq 10^9,W\leq rx-lx+1,H\leq ry-ly+1,1\leq K\leq 10^9,Q\leq 10^3$.

Blank means there are no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号