#P9821. Out of Control

Out of Control

Out of Control

Problem Description

There is a cloud service API to help user store history timestamps. The data structure for each user is initially an empty stack. Every time you post a request to the API with an integer xx, denoting the current timestamp, the service will append xx to the end of the stack. When xx is less than the previous timestamp stored in the stack, the service will think the input is wrong, and will append the previous timestamp instead of xx. You have posted the API for nn times, your request timestamp is xix_i in the ii-th call. However, the network is out of control. The service may receive your requests in any arbitrary order, and may even miss some requests. Knowing this issue, you are asking for the on-call engineer to have a look at your stack in the database. Assume the service received exactly kk requests, how many possible distinct stacks will it be?

Input

The first line contains a single integer TT (1T1001 \leq T \leq 100), the number of test cases. For each test case: The first line of the input contains a single integer nn (1n30001 \leq n \leq 3\,000), denoting the total number of requests. The second line contains nn integers x1,x2,,xnx_1,x_2,\dots,x_n (1xi1091\leq x_i\leq 10^9), denoting the timestamp of each request. It is guaranteed that the sum of all nn is at most 3000030\,000.

Output

For each test case, output nn lines, the ii-th (1in1\leq i\leq n) of which containing an integer, denoting the number of distinct stacks when k=ik=i. Note that the answer may be extremely large, so please print it modulo 109+710^9+7 instead.

Sample Input

2
3
1 2 3
3
2 3 3

Sample Output

3
5
5
2
2
2

Hint

In the first example:

  • When k=1k=1, the stack can be [1][1], [2][2] or [3][3].
  • When k=2k=2, the stack can be [1,2][1,2], [1,3][1,3], [2,2][2,2], [2,3][2,3] or [3,3][3,3].
  • When k=3k=3, the stack can be [1,2,3][1,2,3], [1,3,3][1,3,3], [2,2,3][2,2,3], [2,3,3][2,3,3] or [3,3,3][3,3,3]. In the second example:
  • When k=1k=1, the stack can be [2][2] or [3][3].
  • When k=2k=2, the stack can be [2,3][2,3] or [3,3][3,3].
  • When k=3k=3, the stack can be [2,3,3][2,3,3] or [3,3,3][3,3,3].

Source

2023“钉耙编程”中国大学生算法设计超级联赛(3)