Sequence Artisan

No attempts yetTime limit1sMemory limit256 MB

Problem

Seunghyun builds sequences a1,a2,,aNa_1, a_2, \dots, a_N of length NN for customers who need one. He is early in his career, so he can only build sequences whose elements are integers between 2-2 and 22, and few customers come to him.

Jihak ordered a sequence from him. From the finished sequence Jihak picks one contiguous block ai,ai+1,,aj1,aja_i, a_{i+1}, \dots, a_{j-1}, a_j (1ijN1 \le i \le j \le N) and wants the product of its elements, ai×ai+1××aj1×aja_i \times a_{i+1} \times \dots \times a_{j-1} \times a_j, to be as large as possible. If i=ji = j, the product is aia_i.

Given the sequence Seunghyun built, find the largest product Jihak can obtain.

Input

The first line contains the number of test cases TT (1T1000001 \le T \le 100000). The TT test cases follow.

The first line of each test case contains the length of the sequence NN (2N1000002 \le N \le 100000). The second line contains the elements a1,a2,,aNa_1, a_2, \dots, a_N (2ai2-2 \le a_i \le 2), separated by spaces.

The sum of NN over all test cases does not exceed 300000300000.

Output

For each test case, print the largest product modulo 1,000,000,0071{,}000{,}000{,}007 (=109+7= 10^9 + 7) on its own line.

Compare the true products when choosing the largest one, then reduce only that chosen value modulo 109+710^9 + 7.