Timing

No attempts yetTime limit1sMemory limit128 MB

Problem

A collision between galaxies is coming. The galaxy ruled by MdI wants to annex ours by force. Our intelligence service broke into the enemy headquarters and came back with the whole troop movement plan.

The enemy troops are spread over NN fortresses. Let uiu_i be the power statistic of the troops in fortress ii. The plan moves troops along links. A link (s,d,p)(s, d, p) means that every hour a fraction pp of the troops in fortress ss crosses over to fortress dd. The travel time between fortresses is ignored.

All moves inside one hour happen at the same time and use the values from the start of that hour, so after one hour fortress ii holds

ui=ui(s,d,p):s=ipui+(s,d,p):d=ipusu_i' = u_i - \sum_{(s, d, p) \,:\, s = i} p \cdot u_i + \sum_{(s, d, p) \,:\, d = i} p \cdot u_s

The government picked the hour tt at which the attack starts, so the enemy follows the plan for tt hours. The enemy galaxy is far away and our fleet needs one hour to get there. MdI notices the target the moment the fleet leaves and immediately moves every soldier who can reach it. Direction stops mattering during that hour, so a fortress joined to the target fortress vv by a link sends all of its troops to vv and keeps none.

The power statistic gvg_v gathered at fortress vv when the fleet arrives is therefore uvu_v after tt hours plus the value of every fortress joined to vv by a link. Writing A(v)A(v) for the set of fortresses joined to vv by at least one link, with vv itself left out,

gv=uv+wA(v)uwg_v = u_v + \sum_{w \in A(v)} u_w

Link direction is ignored here, and a fortress counts once even when several links join it to vv.

Find the weakest point of the enemy galaxy, that is the smallest gvg_v over all fortresses.

Input

The first line has the number of test cases TT (1T101 \le T \le 10).

The first line of each test case has the number of enemy fortresses NN (1N1001 \le N \le 100), the number of links ll (0l(N1)20 \le l \le (N-1)^2), and the hour of the attack tt (0t50000 \le t \le 5000). The second line has NN real numbers u0,u1,,uN1u_0, u_1, \dots, u_{N-1} (0ui10000 \le u_i \le 1000), where uiu_i is the power statistic of the troops in fortress ii.

Each of the next ll lines describes one link with an integer sjs_j (0sj<N0 \le s_j < N), an integer djd_j (0dj<N0 \le d_j < N), and a real number pjp_j (0<pj10 < p_j \le 1), meaning that every hour a fraction pjp_j of the troops in fortress sjs_j moves to fortress djd_j. The same pair may appear more than once, and a link with sj=djs_j = d_j is possible. The ratios on the links leaving one fortress add up to at most 1.

Output

For each test case print, on its own line, the value of the weakest point of the enemy galaxy, that is the smallest power statistic that can gather in a single fortress by the time the fleet arrives.

Round the value at the seventh digit after the decimal point and print exactly six digits after the decimal point. If the answer is 305305, print 305.000000. Every input keeps the answer far away from a rounding boundary, so the rounding direction is never in doubt.

Hint

Every link works both ways at the moment the attack starts. A fortress joined to the target by a link sends all of its troops there, whichever way the link points.

The moves during the tt hours before that follow the plan and keep their direction. Only the last hour ignores it.