Blocks
题号:NC236506
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Painting is always a boring job.

There are n blocks on an infinite two-dimensional plane. Each block is a rectangle parallel to the x-axis and y-axis with a non-zero area. 

The coordinates of bottom-left corner and top-right corner of the i-th block are and

There is another block with coordinates of bottom-left corner and top-right corner are (0,0) and (W,H). Nike wants to paint this block black. He will repeatedly choose one of the previous n blocks uniformly at random and independently and fill it black, until the rectangle ((0,0),(W,H)) is completely filled black. 

Find the expected value of the number of times the procedure is done, modulo 998244353. If the procedure is impossible to stop, output -1.

输入描述:

The input contains several test cases, and the first line contains a positive integer  indicating the number of test cases which is up to 500.

For each test case, the first line contains an integer n ().

The second line contains 2 integers W,H ().

Each of the following n lines contains 4 integers (, ), describing the coordinates according to the problem statement.

输出描述:

For each test case, output one line, the answer modulo 998244353. If the procedure is impossible to stop, output -1.

It can be proved that the expected value is always a rational number. Additionally, under the constraints of this problem, when that value is represented as using two coprime integers P and Q, it can be proved that there uniquely exists an integer R such that and . In this case, you should find this R.
示例1

输入

复制
1
8
5 5
0 0 2 2
2 2 5 5
0 2 2 5
2 0 5 2
0 0 1 1
1 1 5 5
0 1 1 5
1 0 5 1

输出

复制
10