Problem: Little Elephant from the Zoo of Lviv hates exams. Since Little Elephant lives in Ukraine, he is going to take exams called 'ZNO'. Help him.
There will be n tickets on the table. Each ticket has a number written on it. The i-th ticket can be numbered Ai with probability Pi percent and with probability 100-Pi percent it can be numbered Bi. It can not have any other number. A numbering of tickets on the table is correct if and only if all tickets have distinct ticket numbers.
Help Little Elephant find the probability that the numbering will be correct.

Input
The first line of the input contains a single integer T - the number of test cases. T test cases follow. The first line of each test case contains a single integer n - the number of tickets on the table. n lines will follow. Each of these lines contains three integers: Pi,  Ai and Bi.

Output
Output T lines, each containing a single real number - answer for the corresponding test case. Rounding errors less than 10^-6 will be ignored.


Constraints

1 <= T <= 10

1 <= n <= 50

1 <= Ai, Bi <= 16

0 <= Pi <= 100


Example

Input:
2
2
50 1 2
50 2 1
3
100 1 3
47 2 1
74 3 2

Output:
0.500000000
0.347800000

Solution (in PYTHON):

Solution:
'''
Little Elephant and Exams

Problem code: LEEXAMS

Little Elephant from the Zoo of Lviv hates exams. Since Little
Elephant lives in Ukraine, he is going to take exams called
'ZNO'. Help him.

There will be n tickets on the table. Each ticket has a number
written on it. The i-th ticket can be numbered Ai with probability Pi
percent and with probability 100-Pi percent it can be numbered Bi. It
can not have any other number. A numbering of tickets on the table is
correct if and only if all tickets have distinct ticket numbers.

Help Little Elephant find the probability that the numbering will be
correct.

Input

The first line of the input contains a single integer T - the number
of test cases. T test cases follow. The first line of each test case
contains a single integer n - the number of tickets on the table. n
lines will follow. Each of these lines contains three integers:
Pi, Ai and Bi.

Output

Output T lines, each containing a single real number - answer for the
corresponding test case. Rounding errors less than 10-6 will be
ignored.

Constraints

1 <= T <= 10
1 <= n <= 50
1 <= Ai, Bi <= 16
0 <= Pi <= 100

Example

Input:
2
2
50 1 2
50 2 1
3
100 1 3
47 2 1
74 3 2

Output:
0.500000000
0.347800000

Author:         witua
Editorial       http://discuss.codechef.com/problems/LEEXAMS
Date Added:     10-04-2012
Time Limit:     1 sec
Source Limit:   50000 Bytes
'''

from sys import stdin

#### Probability - Standard DP
#### codechef September Challenge 2013 >> Little Elephant and Exams

def next_one(k,D,i,A):
    P,a,b = A[i]
    if k & (1<<a) == 0:
        yield k | (1<<a), D[k] * P/100
    if k & (1<<b) == 0:
        yield k | (1<<b), D[k] * (100-P)/100

def solve(A):
    D = dict()
    D[0] = 1.0
    n = len(A)
    for i in range(n):
        T = dict()
        for k in D:
            for kk,v in next_one(k,D,i,A):
                if kk in T:
                    T[kk] += v
                else:
                    T[kk] = v
        D = T
    ans = 0
    for k in D:
        ans += D[k]
    return ans

def check_test(A, B, data='', case=[0]):
    print
    print "test %d:" % case[0]
    print A
    if abs(A-B) > 1e-9:
        if data:
            print data
        print '>>>', A
        print '<<<', B
        print "!!!!!!!! FAIL !!!!!!!!"
    else:
        print ":::::::) OK"
    case[0] += 1

def unit_test():
    print
    A, ans = ((50,1,2),(50,2,1)), 0.500000000
    check_test(solve(A), ans, A)

    A, ans = ((100,1,3),(47,2,1),(74,3,2)), 0.347800000
    check_test(solve(A), ans, A)

def output():
    for case in xrange(1, int(stdin.next()) + 1):
        n = int(stdin.next())
        A = []
        for _ in range(n):
            A.append([int(i) for i in stdin.next().split()])
        ans = solve(A)
        print "%.9f" % ans

if __name__ == '__main__':
#    unit_test()
    output()