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. The risk associated with a debt is the area defined by function and the x axis, i.e. the risk between ∫ risk is just the area above the debt ceiling that can be defined as the integral time t0 and t1 the integral t1 Dc(t). Considering that each client c has a debt ceiling Lc the uncovered t0 ∫ t0 t1 { p(Dc(t) − Lc) where p(x) = x if x≥0 0 if x<0 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: ∑∫ 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. t1 p(Dc(t) − Lc) c t0 ∑∫ t1 Dc (t) c t0

2/2 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%