Under construction

Still being built. Things may change

Expected Number of Connected Components

Time limit5sMemory limit512 MB

Summary
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.
Level

Hard8 of 10

Topics
Probability, Math, Number theory, Union-find
Solved
No attempts yet

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 (T≤100T \le 100).

Each test case takes two lines. The first line has the number of nodes NN (1≤N≤1001 \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 (0≤Pi≤10 \le P_i \le 1, 1≤i≤N1 \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.

Examples3

  1. Example 1

    Input
    2
    4
    0.5 0.5 0.5 0.5
    6
    0.5 0.5 0.5 0.5 0.5 0.5
    
    Expected output
    175000000
    999985132
    
  2. Example 2

    Input
    3
    1
    1
    1
    0
    1
    0.37
    
    Expected output
    100
    0
    37
    
  3. Example 3

    Input
    3
    2
    1.00 1.00
    3
    1 1 1
    5
    1 1 1 1 1
    
    Expected output
    20000
    3000000
    999999727