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 \( D_{c}(t) \) - the debt of client \( c \) at time \( t \), as exemplified bellow.



\resizebox*{0.8\textwidth}{!}{\includegraphics{risk.eps}}



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


\begin{displaymath}
\int ^{t_{1}}_{t_{0}}p(D_{c}(t)-L_{c})\qquad \qquad where\qq...
...d p(x)=\left\{ _{0\Leftarrow x<0}^{x\Leftarrow x\geq 0}\right) \end{displaymath}

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


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

You where was asked 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 description

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 description

You program must write the percentage of uncovered risk, truncated to 2 fractional digits.

Sample input

1

40000 3

35000 30 60

15000 40 70

40000 90 120

Sample output

7.40%

2001-09-24