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

Solution (in CPP):

Solution:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	void set(double arg_rock,double arg_paper,double arg_scissors){
		rock = arg_rock;
		paper = arg_paper;
		scissors = arg_scissors;
	}
	int rating;
	double rock,paper,scissors;
};



int POW[14];
int N,my_rating;
double* dp;
Info info[14];

double recursive(int state){

	if(dp[state] != -1.0)return dp[state];
	if(state == POW[N]-1)return 1.0;

	double ret_rock = 0,ret_paper = 0,ret_scissors = 0;
	int maximum,alive_num,new_loser;
	double calc_1,calc_2,win_rock,win_paper,win_scissors;
	double end_rock,end_paper,end_scissors,finish_rock,finish_paper,finish_scissors;
	vector<int> member;

	member.clear();
	maximum = my_rating;
	alive_num = 0;

	for(int loop = 0; loop < N; loop++){
		if(state & (1 << loop)){
			//Do nothing
		}else{
			member.push_back(loop);
			maximum = max(maximum,info[loop].rating);
			alive_num++;
		}
	}

	finish_rock = finish_paper = finish_scissors = 0.0;

	if(maximum == my_rating){

		end_rock = 0;

		calc_1 = 1.0;
		calc_2 = 1.0;

		for(int i = 0; i < alive_num; i++){
			calc_1 *= (info[member[i]].rock+info[member[i]].scissors);
			calc_2 *= info[member[i]].rock;
		}
		end_rock += calc_1-calc_2;

		calc_1 = 1.0;
		calc_2 = 1.0;

		for(int i = 0; i < alive_num; i++){
			calc_1 *= (info[member[i]].paper+info[member[i]].rock);
			calc_2 *= info[member[i]].rock;
		}
		end_rock += calc_1-calc_2;
		finish_rock = 1.0-end_rock;

		end_scissors = 0.0;

		calc_1 = 1.0;
		calc_2 = 1.0;

		for(int i = 0; i < alive_num; i++){
			calc_1 *= (info[member[i]].scissors+info[member[i]].paper);
			calc_2 *= info[member[i]].scissors;
		}
		end_scissors += calc_1-calc_2;

		calc_1 = 1.0;
		calc_2 = 1.0;

		for(int i = 0; i < alive_num; i++){
			calc_1 *= (info[member[i]].rock+info[member[i]].scissors);
			calc_2 *= info[member[i]].scissors;
		}
		end_scissors += calc_1-calc_2;
		finish_scissors = 1.0-end_scissors;

		end_paper = 0.0;

		calc_1 = 1.0;
		calc_2 = 1.0;

		for(int i = 0; i < alive_num; i++){
			calc_1 *= (info[member[i]].paper+info[member[i]].rock);
			calc_2 *= info[member[i]].paper;
		}
		end_paper += calc_1-calc_2;

		calc_1 = 1.0;
		calc_2 = 1.0;

		for(int i = 0; i < alive_num; i++){
			calc_1 *= (info[member[i]].scissors+info[member[i]].paper);
			calc_2 *= info[member[i]].paper;
		}
		end_paper += calc_1-calc_2;
		finish_paper = 1.0-end_paper;
	}

	for(int i = 0; i < POW[alive_num]; i++){

		new_loser = 0;
		win_rock = 1.0;
		win_paper = 1.0;
		win_scissors = 1.0;

		for(int loop = 0; loop < alive_num; loop++){
			if(i & (1 << loop)){
				win_rock *= info[member[loop]].rock;
				win_paper *= info[member[loop]].paper;
				win_scissors *= info[member[loop]].scissors;
			}else{
				win_rock *= info[member[loop]].scissors;
				win_paper *= info[member[loop]].rock;
				win_scissors *= info[member[loop]].paper;
				new_loser += POW[member[loop]];
			}
		}
		if(new_loser == 0)continue;

		if(state+new_loser == POW[N]-1){
			finish_rock += win_rock;
			finish_paper += win_paper;
			finish_scissors += win_scissors;
			continue;
		}

		ret_rock += win_rock*recursive(state+new_loser);
		ret_paper += win_paper*recursive(state+new_loser);
		ret_scissors += win_scissors*recursive(state+new_loser);
	}

	return dp[state] = max(ret_rock+finish_rock,max(ret_paper+finish_paper,ret_scissors+finish_scissors));
}


int main(){

	for(int i = 0; i < 14; i++)POW[i] = pow(2,i);

	scanf("%d",&N);
	N -= 1;

	scanf("%d",&my_rating);

	double r,p,s;
	for(int i = 0; i < N; i++){
		scanf("%d %lf %lf %lf",&info[i].rating,&r,&p,&s);
		info[i].set(r/100.0,p/100.0,s/100.0);
	}

	dp = new double[POW[N]];
	for(int i = 0; i < POW[N]; i++)dp[i] = -1.0;

	printf("%.10lf\n",recursive(0));
	return 0;
}