For a given permutation a1,a2,⋯,anof length n, we defined the neighbor sequence bof a, the length of which is n−1, as following:
bi={01ai<ai+1ai>ai+1
. For example, the neighbor sequence of permutation 1,2,3,6,4,5is 0,0,0,1,0. Now we give you an integer nand a sequence b1,b2,⋯,bn−1of length n−1, you should calculate the number of permutations of length nwhose neighbor sequence equals to b.
To avoid calculation of big number, you should output the answer module 109+7.
Input
The first line contains one positive integer T(1≤T≤50), denoting the number of test cases. For each test case: The first line of the input contains one integer n,(2≤n≤5000). The second line of the input contains n−1integer: b1,b2,⋯,bn−1 There are no more than 20cases with n>300.
Output
For each test case: Output one integer indicating the answer module 109+7.