409877: GYM103821 I Retirement

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Retirementtime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

After retiring from Competitive Programming coach Ali wanted to discover new horizons and achieve his lifetime dream of buying a farm in the Swiss countryside!

Unlike Farmer John, Coach Ali doesn't want to spend his time running around his cows, years of years in Competitive Programming made him very tired and running around cows is even harder.

Coach Ali bought a farm, and he wants to plant trees in it! There isn't anything much joyful than planting trees and eating fresh fruits everyday. He planted $$$N$$$ trees in different points, tree $$$i$$$ is planted at coordinates $$$X_i, Y_i$$$.

However farming isn't an easy task, there are lots of tasks and challenges, the first one is to make sure that the trees will grow up. Different coordinates have different soil types, and eventually different probability for the trees to grow. Tree planted at point $$$i$$$ has probability $$$\frac{p_i}{100}$$$.

One last thing to consider, watering the trees. You have to buy a rectangular watering system and place it in the farm. This system should have sides parallel to the axes.

Given the point coordinates and the probability of each tree to grow, your task is to find the expected value of the rectangular watering system area.

Input

The first line contains a single integer $$$T$$$ ($$$1\le T \le 10^4$$$) — Number of test cases to process.

The first line of each test case contains a single integer $$$N$$$ ($$$1\le N \le 10^5$$$) — Number of planted trees.

Each of the next $$$N$$$ lines contains three space separated numbers, $$$X_i$$$, $$$Y_i$$$, $$$P_i$$$ ($$$1 \le X_i, Y_i \le 10^5$$$), ($$$0\le P_i \le 100$$$) — Points coordinates, and the probability of each tree to grow.

It is $$$\bf{guaranteed}$$$ that the sum of $$$N$$$ over all test cases does not exceed $$$10^5$$$, and all point coordinates are distinct.

Output

For each test case output the expected value of the rectangular watering system area modulo $$$1\,000\,000\,007$$$.

Formally, let $$$M = 1\,000\,000\,007$$$. It can be shown that the answer can be expressed as an irreducible fraction $$$\frac{p}{q}$$$, where $$$p$$$ and $$$q$$$ are integers and $$$q \not \equiv 0 \pmod{M}$$$. Output the integer equal to $$$p \cdot q^{-1} \bmod M$$$. In other words, output such an integer $$$x$$$ that $$$0 \le x < M$$$ and $$$x \cdot q \equiv p \pmod{M}$$$.

ExampleInput
2
5
2 3 100
5 9 25
4 3 60
2 7 75
8 9 30
3
1 6 33
2 4 20
3 9 100
Output
880000022
298000005

加入题单

算法标签: