#D3033. Janken Master

    ID: 2523 Type: Default 2000ms 536MiB

Janken Master

Janken Master

You are supposed to play the rock-paper-scissors game. There are NN players including you.

This game consists of multiple rounds. While the rounds go, the number of remaining players decreases. In each round, each remaining player will select an arbitrary shape independently. People who show rocks win if all of the other people show scissors. In this same manner, papers win rocks, scissors win papers. There is no draw situation due to the special rule of this game: if a round is tied based on the normal rock-paper-scissors game rule, the player who has the highest programming contest rating (this is nothing to do with the round!) will be the only winner of the round. Thus, some players win and the other players lose on each round. The losers drop out of the game and the winners proceed to a new round. They repeat it until only one player becomes the winner.

Each player is numbered from 11 to NN. Your number is 11. You know which shape the other N1N-1 players tend to show, that is to say, you know the probabilities each player shows rock, paper and scissors. The ii-th player shows rock with ri%r_i\% probability, paper with pi%p_i\% probability, and scissors with si%s_i\% probability. The rating of programming contest of the player numbered ii is aia_i. There are no two players whose ratings are the same. Your task is to calculate your probability to win the game when you take an optimal strategy based on each player's tendency and rating.

Input

The input consists of a single test case formatted as follows.

NN a1a_1 a2a_2 r2r_2 p2p_2 s2s_2 ... aNa_N rNr_N pNp_N sNs_N

The first line consists of a single integer NN (2N142 \leq N \leq 14). The second line consists of a single integer aia_i (1aiN1 \leq a_i \leq N). The (i+1i+1)-th line consists of four integers ai,ri,pia_i, r_i, p_i and sis_i (1aiN,0ri,pi,si100,1 \leq a_i \leq N, 0 \leq r_i, p_i, s_i \leq 100, ri+pi+si=100r_i + p_i + s_i = 100) for i=2,...,Ni=2, ..., N. It is guaranteed that a1,...,aNa_1, ..., a_N are pairwise distinct.

Output

Print the probability to win the game in one line. Your answer will be accepted if its absolute or relative error does not exceed 10610^{-6}.

Examples

Input

2 2 1 40 40 20

Output

0.8

Input

2 1 2 50 50 0

Output

0.5

Input

3 2 1 50 0 50 3 0 0 100

Output

1

Input

3 2 3 40 40 20 1 30 10 60

Output

0.27

Input

4 4 1 34 33 33 2 33 34 33 3 33 33 34

Output

0.6591870816

inputFormat

Input

The input consists of a single test case formatted as follows.

NN a1a_1 a2a_2 r2r_2 p2p_2 s2s_2 ... aNa_N rNr_N pNp_N sNs_N

The first line consists of a single integer NN (2N142 \leq N \leq 14). The second line consists of a single integer aia_i (1aiN1 \leq a_i \leq N). The (i+1i+1)-th line consists of four integers ai,ri,pia_i, r_i, p_i and sis_i (1aiN,0ri,pi,si100,1 \leq a_i \leq N, 0 \leq r_i, p_i, s_i \leq 100, ri+pi+si=100r_i + p_i + s_i = 100) for i=2,...,Ni=2, ..., N. It is guaranteed that a1,...,aNa_1, ..., a_N are pairwise distinct.

outputFormat

Output

Print the probability to win the game in one line. Your answer will be accepted if its absolute or relative error does not exceed 10610^{-6}.

Examples

Input

2 2 1 40 40 20

Output

0.8

Input

2 1 2 50 50 0

Output

0.5

Input

3 2 1 50 0 50 3 0 0 100

Output

1

Input

3 2 3 40 40 20 1 30 10 60

Output

0.27

Input

4 4 1 34 33 33 2 33 34 33 3 33 33 34

Output

0.6591870816

样例

2
2
1 40 40 20
0.8