Permutation

아직 제출이 없습니다시간 제한3초메모리 제한256 MB

문제

Chiaki has a permutation p_1,p_2,,p_np\_1,p\_2,\dots,p\_n of integers 1,2,,n1,2,\dots,n with some unknown positions. She would like to know the number of ways to fill the unknown positions such that the resulting permutation contains a subsequence of length at least 33 that is an arithmetic progression.

As the number may be very large, you are only asked to calculate it modulo 109+710^9 + 7.

입력

There are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case:

The first line contains an integer nn (1n501 \le n \le 50): the length of the permutation.

The second line contains nn integers p_1,p_2,,p_np\_1,p\_2,\dots,p\_n (0p_in0 \le p\_i \le n), where p_i=0p\_i=0 means that p_ip\_i is unknown, and all non-zero elements are distinct.

It is guaranteed that the sum of nn in all test cases does not exceed 5050.

출력

For each test case, output an integer denoting the answer.