#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int rate[1001];
double per[15][3];
double dp[15][1<<14][1<<3];
double dp2[1<<14];

double solve(int bit){
	if(dp2[bit]>=-0.1)return dp2[bit];
	if(bit==0)return 1.0;
	double res=0.0;
	for(int i=0;i<3;i++){
		double now=0.0;
		for(int j=1;j<8;j++){
			int nbit=j|(1<<i);
			if(nbit==1 || nbit==2 || nbit==4 || nbit==7){
				bool flag=true;
				for(int k=0;k<n-1;k++){
					if(rate[n-1]<rate[k] && (bit>>k & 1))flag=false;
				}
				if(flag)now+=dp[n-1][bit][j];
			}else{
				if(nbit==3 && i==0)continue;
				if(nbit==5 && i==2)continue;
				if(nbit==6 && i==1)continue;
				for(int k=(bit-1)&bit;k>=0;k=(k-1)&bit){
					double pr=1.0;
					int rest=3;
					if(nbit==3 && j==2)rest=2;
					if(nbit==3 && j==1)rest=1;
					if(nbit==5 && j==1)rest=2;
					if(nbit==5 && j==4)rest=1;
					if(nbit==6 && j==4)rest=2;
					if(nbit==6 && j==2)rest=1;

					for(int l=0;l<n-1;l++){
						if(!(bit>>l & 1))continue;
						if(nbit==3){
							if(k>>l & 1){
								if(j==1)pr=0.0;
								pr*=per[l][1];
								if(rest>=2)rest-=2;
							}
							else{
								if(j==2)pr=0.0;
								pr*=per[l][0];
								if(rest%2==1)rest-=1;
							}
						}
						if(nbit==5){
							if(k>>l & 1){
								if(j==4)pr=0.0;
								pr*=per[l][0];
								if(rest>=2)rest-=2;
							}else{
								if(j==1)pr=0.0;
								pr*=per[l][2];
								if(rest%2==1)rest-=1;
							}
						}
						if(nbit==6){
							if(k>>l & 1){
								if(j==2)pr=0.0;
								pr*=per[l][2];
								if(rest>=2)rest-=2;
							}else{
								if(j==4)pr=0.0;
								pr*=per[l][1];
								if(rest%2==1)rest-=1;
							}
						}
					}
					if(rest==0 && pr>1e-15)now+=pr*solve(k);
					if(k==0)break;
				}
			}
		}
		res=max(res,now);
	}
	dp2[bit]=res;
	return dp2[bit];
}

int main(void){
	scanf("%d",&n);
	scanf("%d",&rate[n-1]);
	for(int i=0;i<n-1;i++){
		scanf("%d",&rate[i]);
		for(int j=0;j<3;j++){
			scanf("%lf",&per[i][j]);
			per[i][j]/=100.0;
		}
	}
	for(int i=0;i<(1<<(n-1));i++){
		dp[0][i][0]=1.0;
	}
	for(int i=0;i<n-1;i++){
		for(int j=0;j<1<<(n-1);j++){
			for(int k=0;k<8;k++){
				if(dp[i][j][k]<1e-15)continue;
				if(j>>i & 1){
					for(int l=0;l<3;l++){
						dp[i+1][j][k|(1<<l)]+=dp[i][j][k]*per[i][l];
					}
				}else{
					dp[i+1][j][k]=dp[i][j][k];
				}
			}
		}
	}
	for(int i=0;i<(1<<n-1);i++){
		dp2[i]=-1.0;
	}
	printf("%.12f\n",solve((1<<n-1)-1));
	return 0;
}
### Prompt

Create a solution in cpp for the following problem:

You are supposed to play the rock-paper-scissors game. There are $N$ 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 $1$ to $N$. Your number is $1$. You know which shape the other $N-1$ players tend to show, that is to say, you know the probabilities each player shows rock, paper and scissors. The $i$-th player shows rock with $r_i\%$ probability, paper with $p_i\%$ probability, and scissors with $s_i\%$ probability. The rating of programming contest of the player numbered $i$ is $a_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.


$N$
$a_1$
$a_2$ $r_2$ $p_2$ $s_2$
...
$a_N$ $r_N$ $p_N$ $s_N$


The first line consists of a single integer $N$ ($2 \leq N \leq 14$). The second line consists of a single integer $a_i$ ($1 \leq a_i \leq N$). The ($i+1$)-th line consists of four integers $a_i, r_i, p_i$ and $s_i$ ($1 \leq a_i \leq N, 0 \leq r_i, p_i, s_i \leq 100,$ $r_i + p_i + s_i = 100$) for $i=2, ..., N$. It is guaranteed that $a_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 $10^{-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

### Response

```cpp
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int rate[1001];
double per[15][3];
double dp[15][1<<14][1<<3];
double dp2[1<<14];

double solve(int bit){
	if(dp2[bit]>=-0.1)return dp2[bit];
	if(bit==0)return 1.0;
	double res=0.0;
	for(int i=0;i<3;i++){
		double now=0.0;
		for(int j=1;j<8;j++){
			int nbit=j|(1<<i);
			if(nbit==1 || nbit==2 || nbit==4 || nbit==7){
				bool flag=true;
				for(int k=0;k<n-1;k++){
					if(rate[n-1]<rate[k] && (bit>>k & 1))flag=false;
				}
				if(flag)now+=dp[n-1][bit][j];
			}else{
				if(nbit==3 && i==0)continue;
				if(nbit==5 && i==2)continue;
				if(nbit==6 && i==1)continue;
				for(int k=(bit-1)&bit;k>=0;k=(k-1)&bit){
					double pr=1.0;
					int rest=3;
					if(nbit==3 && j==2)rest=2;
					if(nbit==3 && j==1)rest=1;
					if(nbit==5 && j==1)rest=2;
					if(nbit==5 && j==4)rest=1;
					if(nbit==6 && j==4)rest=2;
					if(nbit==6 && j==2)rest=1;

					for(int l=0;l<n-1;l++){
						if(!(bit>>l & 1))continue;
						if(nbit==3){
							if(k>>l & 1){
								if(j==1)pr=0.0;
								pr*=per[l][1];
								if(rest>=2)rest-=2;
							}
							else{
								if(j==2)pr=0.0;
								pr*=per[l][0];
								if(rest%2==1)rest-=1;
							}
						}
						if(nbit==5){
							if(k>>l & 1){
								if(j==4)pr=0.0;
								pr*=per[l][0];
								if(rest>=2)rest-=2;
							}else{
								if(j==1)pr=0.0;
								pr*=per[l][2];
								if(rest%2==1)rest-=1;
							}
						}
						if(nbit==6){
							if(k>>l & 1){
								if(j==2)pr=0.0;
								pr*=per[l][2];
								if(rest>=2)rest-=2;
							}else{
								if(j==4)pr=0.0;
								pr*=per[l][1];
								if(rest%2==1)rest-=1;
							}
						}
					}
					if(rest==0 && pr>1e-15)now+=pr*solve(k);
					if(k==0)break;
				}
			}
		}
		res=max(res,now);
	}
	dp2[bit]=res;
	return dp2[bit];
}

int main(void){
	scanf("%d",&n);
	scanf("%d",&rate[n-1]);
	for(int i=0;i<n-1;i++){
		scanf("%d",&rate[i]);
		for(int j=0;j<3;j++){
			scanf("%lf",&per[i][j]);
			per[i][j]/=100.0;
		}
	}
	for(int i=0;i<(1<<(n-1));i++){
		dp[0][i][0]=1.0;
	}
	for(int i=0;i<n-1;i++){
		for(int j=0;j<1<<(n-1);j++){
			for(int k=0;k<8;k++){
				if(dp[i][j][k]<1e-15)continue;
				if(j>>i & 1){
					for(int l=0;l<3;l++){
						dp[i+1][j][k|(1<<l)]+=dp[i][j][k]*per[i][l];
					}
				}else{
					dp[i+1][j][k]=dp[i][j][k];
				}
			}
		}
	}
	for(int i=0;i<(1<<n-1);i++){
		dp2[i]=-1.0;
	}
	printf("%.12f\n",solve((1<<n-1)-1));
	return 0;
}
```