

FirefliesTime Limit: 5000/2500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 179 Accepted Submission(s): 69 Problem Description Randal is a master of highdimensional space. All the species living in his space are regarded as fireflies for him. One day he came up with a problem but failed to solve it. Are you the one who can solve that? There is one $n$dimensional hypercubic subspace that he wants to cover by the minimal number of fireflies. The side lengths of the space are $p_1, p_2, \cdots, p_n$, which means this space can be formed into $\prod_{i = 1}^{n}{p_i}$ hypercubic units. One unit is considered as covered if there exists a firefly that has visited it. Each firefly is able to cover several units through its own traveling. Assuming a firefly is located at the coordinate $(x_1, x_2, \cdots, x_n)$ with $1 \leq x_i \leq p_i$ $(i = 1, 2, \cdots, n)$, it can move to another coordinate $(y_1, y_2, \cdots, y_n)$ if $1 \leq x_i \leq y_i \leq p_i$ $(i = 1, 2, \cdots, n)$ and $\sum_{i = 1}^{n}{x_i  y_i} = 1$. In addition, The travel of one firefly can start or end at any location and might have any times of moves but one firefly could only travel once. Your task is to determine the minimum number of fireflies that should be involved and print the answer in modulo $(10^9 + 7)$. Input The first line contains one integer $T$, indicating the number of test cases. The following lines describe all the test cases. For each test case: The first line contains one integer $n$, indicating the dimension of the space. The second line contains $n$ spaceseparated integers, indicating the side lengths of the space. $1 \leq T \leq 2000$, $1 \leq n \leq 32$, $1 \leq p_i \leq 10^9$ $(i = 1, 2, \cdots, n)$. It is guaranteed that no more than $200$ test cases satisfy $n > 8$, no more than $20$ test cases satisfy $n > 16$ and no more than $2$ test cases satisfy $n > 24$. Output For each test case, print the answer modulo $(10^9 + 7)$ in one line. Sample Input
Sample Output
Hint For the first sample, one firefly could cover all the units. For the second sample, one possible best way is that each firefly covers all the units with the same second coordinate, which involves three fireflies. Source  
