Financial Risk 

As a rule the ACME Corporation clients pay within 30 days from shipment. Nevertheless, there is the risk that a client may be unable to fulfill its responsibility. The ACME Corporation transfered this risk to a financial insurance company that covers the responsibility of each customer up to a certain debt ceiling, depending on the customer financial record.

In order not to displease its clients the policy of the ACME Corporation is to continue selling to a client after reaching the debt ceiling imposed by the financial insurance company. In this case the risk above the debt ceiling is assumed by the ACME Corporation.

The CEO of the ACME Corporation has to decide if the client's debt ceiling needs to be renegotiated with the financial insurance company. For that she wants to know what percentage of the client's debt is not being covered by the insurance company in the present deal.

The ACME Financial Department came up with a formula to measure a client risk. Consider the step function Dc(t) - the debt of client c at time t, as exemplified bellow.

\epsfbox{p832.eps}

The risk associated with a debt is the area defined by function and the x axis, i.e. the risk between time t0 and t1 the integral $ \int^{t_{1}}_{t_{0}}$Dc(t). Considering that each client c has a debt ceiling Lc the uncovered risk is just the area above the debt ceiling that can be defined as the integral

$\displaystyle \int^{t_{1}}_{t_{0}}$p(Dc(t) - Lc)                where                p(x) = $\displaystyle \cases{x & if \quad $x \ge 0$ \cr 0 & if \quad $x < 0$ \cr}
$

Thus, the percentage of uncovered risk for all clients is the quotient of the sum of all uncovered risks by the sum of all risks, as given by the following formula:

$\displaystyle {\frac{\sum _{c}\: \int ^{t_{1}}_{t_{0}}\: p(D_{c}(t)-L_{c})}{\sum _{c}\:
\int ^{t_{1}}_{t_{0}}\: D_{c}(t)}}$

Your task is to write a program to compute the percentage of uncovered risk in the last fiscal year, using the formula above and the data provided by a listing of the ACME's ERP.

Input 

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.


The listing you will use as input starts with the number of clients with sales in the last fiscal year. For each client the first line has the debt limit and the number of sales. In the following lines, one for each sale, there is the sale's value, the day of the year of the invoice and the day of the year of the receipt.

Output 

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.


Your program must write the percentage of uncovered risk, truncated to 2 fractional digits. Note that the output must include the percent sign (`%').

Sample Input 

1

2
40000 3
35000 32 61
15000 45 72
40000 97 123
55000 4
12000 10 52
30000 32 64
33000 44 73
50000 62 94

Sample Output 

11.85%



Jose Paulo Leal, MIUP'2001