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 <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 13;

double dp[(1 << MAX_N)];
double gu[(1 << MAX_N)],ch[(1 << MAX_N)],pa[(1 << MAX_N)];
bool ok[(1 << MAX_N)];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n--;
    int a;
    cin >> a;
    vector<int> vec(n);
    vector<double> r(n),p(n),s(n);
    rep(i,n){
        int x,y,z;
        cin >> vec[i] >> x >> y >> z;
        r[i] = x / 100.0,p[i] = y / 100.0,s[i] = z/100.0;
    }
    rep(i,(1<<n)){
        int mx = a;
        rep(j,n){
            if(i & (1 << j)){
                mx = max(mx,vec[j]);
            }
        }
        if(mx == a){
            ok[i] = true;
        }
    }
    rep(i,(1<<n)){
        double res1 = 1.0,res2 = 1.0,res3 = 1.0;
        rep(j,n){
            if(i & (1 << j)){
                res1 *= r[j],res2 *= p[j],res3 *= s[j];
            }
        }
        gu[i] = res1,ch[i] = res3,pa[i] = res2;
    }
    dp[0] = 1.0;
    for(int i=1;i<(1<<n);i++){
        double g=0,c=0,p=0;
        for(int j=i;j>=0;j=(j-1)&i){
            if(j != i){
                g += gu[j]*ch[i^j]*dp[j];
                c += ch[j]*pa[i^j]*dp[j];
                p += pa[j]*gu[i^j]*dp[j];
            }
            if(j == 0){
                break;
            }
        }
        if(ok[i]){
            double mg=0,mc=0,mp=0;
            for(int j=i;j>=0;j=(j-1)&i){
                if(j != i){
                    mg += gu[j]*pa[i^j];
                    mc += ch[j]*gu[i^j];
                    mp += pa[j]*ch[i^j];
                }
                if(j == 0){
                    break;
                }
            }
            for(int j=i;j>=0;j=(j-1)&i){
                if(j != i){
                    mg += gu[j]*ch[i^j];
                    mc += ch[j]*pa[i^j];
                    mp += pa[j]*gu[i^j];
                }
                if(j == 0){
                    break;
                }
            }
            g += 1-mg,c += 1-mc,p += 1-mp;
        }
        dp[i] = max(g,max(c,p));
    }
    printf("%.12lf\n",dp[(1 << n)-1]);
    return 0;
}