Random signals

No attempts yetTime limit12sMemory limit256 MB

Problem

There are NN signal stations on the plane, numbered 1 to NN. Station ii is at (xi,yi)(x_i, y_i) and broadcasts into a disk centered at that point. The radius and the strength of a broadcast depend on how much power the station receives.

Station ii can send MiM_i different signals, named (i,1)(i, 1) through (i,Mi)(i, M_i). Signal (i,j)(i, j) has radius ri,jr_{i,j} and strength si,js_{i,j}, and station ii always sends it once the power that reaches the station is at least wi,jw_{i,j}. So when station ii receives power pp, every signal (i,j)(i, j) with wi,jpw_{i,j} \le p goes out, and each of those signals covers every point of the closed disk with center (xi,yi)(x_i, y_i) and radius ri,jr_{i,j}.

The strength delivered to a point (x,y)(x, y) is the largest strength among the signals that cover it. If no signal covers the point, the strength there is 00. The government measures how far the signals spread with the value AA below.

A=ss×(area of the region whose strength is exactly s)A = \sum_s s \times (\text{area of the region whose strength is exactly } s)

Each day the government picks the power for station ii among the integers in [Li,Ui][L_i, U_i]. Every integer is equally likely, and the stations are chosen independently of each other. Compute the expected value of AA.

Input

The first line contains the number of stations NN (1N201 \le N \le 20).

The descriptions of the NN stations follow in order, starting with station 1. The first line of each description contains five integers xx, yy (104x,y104-10^4 \le x, y \le 10^4), MM (1M201 \le M \le 20), LL and UU (1LU1041 \le L \le U \le 10^4), separated by spaces. Each of the next MM lines contains three integers rr, ss and ww (1r,s,w1041 \le r, s, w \le 10^4), separated by spaces.

Output

Print the expected value of AA on one line, rounded to six digits after the decimal point. Print exactly six digits after the decimal point.

Every input satisfies two guarantees: the expected value is smaller than 10610^6, and it is at least 10910^{-9} away from the boundary where rounding to six decimal digits switches between rounding up and rounding down.