#P6657. 【模板】LGV 引理
【模板】LGV 引理
Description
This is a template problem.
There is an chessboard, with the bottom-left corner at and the top-right corner at . If a piece is at , then in one step it can only move to or .
Now there are pieces. The -th piece starts at and must finally move to . Ask how many valid plans there are such that every piece can move from its start to its end, and for all pieces, the points on their paths are pairwise disjoint. Output the number of plans modulo .
Two plans are different if and only if there exists at least one piece whose visited points are different.
Input Format
This problem has multiple test cases.
The first line contains an integer , representing the number of test cases in this testdata.
For each test case:
The first line contains two integers , representing the size of the board and the number of start/end pairs.
The next lines each contain integers , whose meaning has been explained in the description.
Output Format
For each test case, output one line containing one integer, representing the number of plans modulo .
3
3 2
1 2
2 3
5 2
1 3
3 5
10 5
3 5
4 7
5 8
7 9
9 10
3
155
2047320
Hint
-
For of the testdata, , .
-
For of the testdata, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号