Ron is a master of a ramen shop.
Recently, he has noticed some customers wait for a long time. This has been caused by lack of seats during lunch time. Customers loses their satisfaction if they waits for a long time, and even some of them will give up waiting and go away. For this reason, he has decided to increase seats in his shop. To determine how many seats are appropriate, he has asked you, an excellent programmer, to write a simulator of customer behavior.
Customers come to his shop in groups, each of which is associated with the following four parameters:
The i-th group comes to the shop with P_{i} customers together at the time T_{i} . If P_{i} successive seats are available at that time, the group takes their seats immediately. Otherwise, they waits for such seats being available. When the group fails to take their seats within the time W_{i} (inclusive) from their coming and strictly before the closing time, they give up waiting and go away. In addition, if there are other groups waiting, the new group cannot take their seats until the earlier groups are taking seats or going away.
The shop has N counters numbered uniquely from 1 to N. The i-th counter has C_{i} seats. The group prefers gseats with a greater distance to the nearest group.h Precisely, the group takes their seats according to the criteria listed below. Here, S_{L} denotes the number of successive empty seats on the left side of the group after their seating, and S_{R} the number on the right side. S_{L} and S_{R} are considered to be infinity if there are no other customers on the left side and on the right side respectively.
When multiple groups are leaving the shop at the same time and some other group is waiting for available seats, seat assignment for the waiting group should be made after all the finished groups leave the shop.
Your task is to calculate the average satisfaction over customers. The satisfaction of a customer in the i-th group is given as follows:
The input consists of multiple datasets.
Each dataset has the following format:
N M T C_{1} C_{2} ... C_{N} T_{1} P_{1} W_{1} E_{1} T_{2} P_{2} W_{2} E_{2} ... T_{M} P_{M} W_{M} E_{M}
N indicates the number of counters, M indicates the number of groups and T indicates the closing time. The shop always opens at the time 0. All input values are integers.
You can assume that 1 ≤ N ≤ 100, 1 ≤ M ≤ 10000, 1 ≤ T ≤ 10^{9}, 1 ≤ C_{i} ≤ 100, 0 ≤ T_{1} < T_{2} < ... < T_{M} < T, 1 ≤ P_{i} ≤ max C_{i}, 1 ≤ W_{i} ≤ 10^{9} and 1 ≤ E_{i} ≤ 10^{9}.
The input is terminated by a line with three zeros. This is not part of any datasets.
For each dataset, output the average satisfaction over all customers in a line. Each output value may be printed with an arbitrary number of fractional digits, but may not contain an absolute error greater than 10^{-9}.
1 4 100 7 10 1 50 50 15 2 50 50 25 1 50 50 35 3 50 50 1 2 100 5 30 3 20 50 40 4 40 50 1 2 100 5 49 3 20 50 60 4 50 30 1 2 100 5 50 3 20 50 60 4 50 30 2 3 100 4 2 10 4 20 20 30 2 20 20 40 4 20 20 0 0 0
0.7428571428571429 0.4285714285714285 0.5542857142857143 -0.1428571428571428 0.8000000000000000