#P7832. Kirakira
Kirakira
Kirakira
Problem Description
There are stars in the sky. At every moment, the -th of them has a probability of to become visible. All stars are independent of each other. The position of a star can be described as a coordinate on a 2D plane. No two stars share the same coordinate. Your task is to compute the expectation value of the area of the convex hull formed by the visible stars. Formally, let . It can be shown that the answer can be expressed as an irreducible fraction , where and are integers and . Output the integer equal to . In other words, output such an integer that and .
Input
The first line contains a single integer (), denoting the number of test cases. For each test case, the first line contains a single integer , denoting the number of stars. Each of the following lines describes a stars. The -th line of them contains 4 integers $x_i, y_i, u_i, v_i(-1000 \le x_i,y_i \le 1000, 1 \leq u_i < v_i<P=31607)$ indicating the coordinate of the -th star and the probability of the -th star to become visible. It is guaranteed that no two stars share the same coordinate. There are at most test cases satisfying .
Output
Output the integer equal to denoting the answer.
Sample Input
2
4
0 0 1 2
1 0 1 2
0 1 1 2
1 1 1 2
4
0 0 1 2
1 0 1 2
-1 0 1 2
0 1 1 2
Sample Output
21730
21730
Source
2020 Multi-University Training Contest 6