Under construction

Still being built. Things may change

Minimum Spanning Trees

Time limit4sMemory limit512 MB

Summary
Given a random graph where each edge has weight 0 to k or is absent, find for each s the probability that the graph is connected with MST weight s, modulo 1e9+7.
Level

Hard8 of 10

Topics
Dynamic programming, Probability, Combinatorics, Graph
Solved
No attempts yet

Problem

One day, Subconscious faced a problem that reminded him of a horrible experience in a past contest. In that contest, the easiest problem asked for the number of minimum spanning trees in a randomly generated graph.

Now there is a graph with nn vertices labeled from 1 to nn. For each pair of vertices uu and vv (1≤u<v≤n1 \le u < v \le n), there is no edge between them with probability p0/100p_0/100, or an edge of weight 1 with probability p1/100p_1/100, or an edge of weight 2 with probability p2/100p_2/100, and so on, up to an edge of weight kk with probability pk/100p_k/100, where kk is the maximum weight of an edge. All edges are generated independently.

The task is not to find the expected weight of the minimum spanning tree, since the graph may be disconnected and the task author does not know how to deal with such cases. Instead, for each integer ss between n−1n - 1 and k(n−1)k(n - 1), calculate the probability that the graph is connected and the weight of its minimum spanning tree is exactly ss.

Subconscious thinks he has solved the problem, but he is not sure his solution is correct. He wants to check the answers modulo 1,000,000,007 with you.

Input

The input contains several test cases. The first line contains a single integer TT (1≤T≤2001 \le T \le 200), the number of test cases.

Each test case starts with two integers nn (2≤n≤402 \le n \le 40) and kk (1≤k≤41 \le k \le 4), the number of vertices and the maximum edge weight. The next line contains k+1k + 1 non-negative integers p0,p1,…,pkp_0, p_1, \ldots, p_k with ∑i=0kpi=100\sum_{i=0}^{k} p_i = 100.

At most 20 test cases have n>10n > 10, and at most 2 test cases have n>20n > 20.

Output

For each test case, print one line with (k−1)(n−1)+1(k - 1)(n - 1) + 1 integers. The ii-th integer is the probability that the graph is connected and its minimum spanning tree has weight exactly n−2+in - 2 + i, reported modulo 1,000,000,007.

More precisely, if the reduced fraction of the probability is p/qp/q, print the minimum non-negative integer rr such that q⋅r≡p(mod1000000007)q \cdot r \equiv p \pmod{1000000007}. You may assume such rr always exists in all test cases.

Examples1

  1. Example 1

    Input
    2
    3 1
    50 50
    3 2
    0 50 50
    
    Expected output
    500000004
    500000004 375000003 125000001