As the title implies, your task in this problem is related to maze, specifically a 2D maze of

rows and

columns (

), where rows are numbered from

to

from top to bottom, and columns are numbered from 1 to

from left to right. The cell at the i-th row and the j-th column is denoted by
%7D)
.
The maze has only one entry which is at
%7D)
and only one exit which is at
)
. To simplify things, you are only allowed to move right or down at any step. There might be cells with obstacle which cannot be visited, and there might be cells with treasure which must be visited.
In this problem, you are requested to count the number of valid paths from the starting location to the ending location.
There are

cells with treasure. The valid path should visit all cells with treasure.
The following cells with obstacle, the valid path cannot visit any cell with obstacle.
- all cells
meet
, - all cells
meet
, - and there are
additional cells with obstacle.
输入描述:
The first line of the input gives the number of test case,
(
).
test cases follow.
Each test case consists of one line with four integers
,
,
, and
as described above. (
,
,
)
Then,
lines follow. Each line consists of
integers
and
, indicating the cells with treasure in the maze. (
,
,
,
) (no two cells are in the same position)
After that, there are
lines. Each line consists of
integers
and
, indicating the cells with obstacle in the maze. (
,
,
,
) (no two cells are in the same position)
输出描述:
For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1) and y is the number of valid paths module 1,000,000,007 (
).
示例1
输入
复制
2
2 3 0 0
3 6 1 1
2 4
1 3
说明
In Sample Case #1, one valid path are:
In Sample Case #2, two valid paths are: