Expected Number of Connected Components

For each node i with inclusion probability P_i, find the expected number of connected components of the subgraph where two selected nodes are adjacent when gcd > 1, then print E times 100^N mod 1e9+7.

Hard8ProbabilityMathNumber theoryUnion-findNo attempts yetTime limit5sMemory limit512 MB

Problem

There are NN nodes, numbered with the distinct integers from 1 to NN. You pick a random subset of these nodes. Node ii enters the subset with probability PiP_i, independently of every other node.

Two nodes in the subset are joined by an edge when the greatest common divisor of their numbers is larger than 1. Find the expected number of connected components of the resulting subgraph.

Input

The first line has the number of test cases TT (T100T \le 100).

Each test case takes two lines. The first line has the number of nodes NN (1N1001 \le N \le 100). The second line has NN real numbers separated by spaces. The ii-th real number PiP_i is the probability that node ii is in the subset (0Pi10 \le P_i \le 1, 1iN1 \le i \le N). Each real number is given with at most two digits after the decimal point.

Output

For each test case, let EE be the expected number of connected components. Print E×100NE \times 100^N modulo 10000000071000000007 on its own line. The value E×100NE \times 100^N is always an integer.

Notes

The greatest common divisor of node 1 and any other node is 1, so node 1 always forms a component by itself when it is in the subset.

Take N=4N = 4 with all four probabilities equal to 0.50.5. Each of the 16 subsets appears with probability 0.06250.0625, and the component counts of those 16 subsets add up to 28. The expected value is 28/16=1.7528 / 16 = 1.75, so the value to print is 1.75×1004=1750000001.75 \times 100^4 = 175000000.