#D3033. Janken Master
Janken Master
Janken Master
You are supposed to play the rock-paper-scissors game. There are 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 to . Your number is . You know which shape the other players tend to show, that is to say, you know the probabilities each player shows rock, paper and scissors. The -th player shows rock with probability, paper with probability, and scissors with probability. The rating of programming contest of the player numbered is . 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.
...
The first line consists of a single integer (). The second line consists of a single integer (). The ()-th line consists of four integers and ( ) for . It is guaranteed that 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 .
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.
...
The first line consists of a single integer (). The second line consists of a single integer (). The ()-th line consists of four integers and ( ) for . It is guaranteed that 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 .
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