Problem1259--LIS

1259: LIS

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 0  Solved: 0
[Submit] [Status] [Web Board] [Creator:]

Description

Edward has an sequence of n positive integers {a1, a2, ..., an}. He soon finds the LIS (longest increasing subsequence) of the sequence. 

But Edward is not satisfied with the result. So he wants to modify an element of the sequence to another positive integer and make the length of LIS longer. 

Now Edward gives the sequence to you, and he wants to know how many elements can be modified to make the length of LIS longer. 

Sequence {s1, s2, ..., sr} of length r is a subsequence of sequence {a1, a2, ..., an}, if there is such increasing sequence of indexes i1, i2, ..., ir (1 <=  i1 < i2 < ... < ir <= n), that aij = sj. 

Sequence {s1, s2, ..., sr} is increasing, if the following inequality holds: s1 < s2 < ... < sr.

Input

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

The first line contains an integer n (1 <= n <= 100000), indicating the length of the sequence. The following line contains n integers a1, a2, ..., an (1 <= ai <= 10^9), indicating the given sequence.

Output

For each test case, output an integer s on the first line, indicating the total number of elements which satisfy the description above. The following line contains s integers p1, p2, ..., ps in increasing order, where pi is the index of the element in the given sequence (indexes are 1-based). 

If s is equal to 0, the second line should be an empty line.

Sample Input Copy

3
3
1 2 3
3
1 3 2
4
2 2 3 2

Sample Output Copy

0

1
3
2
1 4

HINT

For the first sample, the length of LIS of original sequence is 3. And no matter which element we modify the length of LIS won't be larger than 3. 
For the second sample, the length of LIS of original sequence is 2. We can only modify 2 to another integer greater than 3, such as 4. So the length of LIS after 
modification is 3.     

Source/Category