#P1794C. Scoring Subsequences

    ID: 8277 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>binary searchgreedymathtwo pointers

Scoring Subsequences

No submission language available for this problem.

Description

The score of a sequence [s1,s2,,sd][s_1, s_2, \ldots, s_d] is defined as s1s2sdd!\displaystyle \frac{s_1\cdot s_2\cdot \ldots \cdot s_d}{d!}, where d!=12dd!=1\cdot 2\cdot \ldots \cdot d. In particular, the score of an empty sequence is 11.

For a sequence [s1,s2,,sd][s_1, s_2, \ldots, s_d], let mm be the maximum score among all its subsequences. Its cost is defined as the maximum length of a subsequence with a score of mm.

You are given a non-decreasing sequence [a1,a2,,an][a_1, a_2, \ldots, a_n] of integers of length nn. In other words, the condition a1a2ana_1 \leq a_2 \leq \ldots \leq a_n is satisfied. For each k=1,2,,nk=1, 2, \ldots , n, find the cost of the sequence [a1,a2,,ak][a_1, a_2, \ldots , a_k].

A sequence xx is a subsequence of a sequence yy if xx can be obtained from yy by deletion of several (possibly, zero or all) elements.

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains an integer nn (1n1051\le n\le 10^5) — the length of the given sequence.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ain1\le a_i\leq n) — the given sequence. It is guaranteed that its elements are in non-decreasing order.

It is guaranteed that the sum of nn over all test cases does not exceed 51055\cdot 10^5.

For each test case, output nn integers — the costs of sequences [a1,a2,,ak][a_1, a_2, \ldots , a_k] in ascending order of kk.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains an integer nn (1n1051\le n\le 10^5) — the length of the given sequence.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ain1\le a_i\leq n) — the given sequence. It is guaranteed that its elements are in non-decreasing order.

It is guaranteed that the sum of nn over all test cases does not exceed 51055\cdot 10^5.

Output

For each test case, output nn integers — the costs of sequences [a1,a2,,ak][a_1, a_2, \ldots , a_k] in ascending order of kk.

Sample Input 1

3
3
1 2 3
2
1 1
5
5 5 5 5 5

Sample Output 1

1 1 2 
1 1 
1 2 3 4 5

Note

In the first test case:

  • The maximum score among the subsequences of [1][1] is 11. The subsequences [1][1] and [][] (the empty sequence) are the only ones with this score. Thus, the cost of [1][1] is 11.
  • The maximum score among the subsequences of [1,2][1, 2] is 22. The only subsequence with this score is [2][2]. Thus, the cost of [1,2][1, 2] is 11.
  • The maximum score among the subsequences of [1,2,3][1, 2, 3] is 33. The subsequences [2,3][2, 3] and [3][3] are the only ones with this score. Thus, the cost of [1,2,3][1, 2, 3] is 22.
Therefore, the answer to this case is 1  1  21\:\:1\:\:2, which are the costs of [1],[1,2][1], [1, 2] and [1,2,3][1, 2, 3] in this order.