3secv

Time limit: 0.5s Memory limit: 1MB Input: Output:

"And when you think that they actually made the tests for joingraf..."

Task

After conducting the tests for the joingraph problem at the last RoAlgo contest, the committee realized that a special problem was still needed. After extensive discussions, the following problem was created:

Given tt arrays aa of nn numbers, find the length of the longest subarray that contains at most 33 distinct numbers. An example of such a subarray is: 9 1 09 \ 1 \ 0.

Input data

The first line of the input contains the number tt. For each test, the first line contains nn, representing the number of numbers. The second line contains the nn numbers.

Output data

For each test, print the maximum length of a subarray with at most 33 distinct numbers.

Constraints and clarifications

  • 1t1 0001 \leq t \leq 1\ 000
  • 1n1061 \leq n \leq 10^6
  • The sum of the lengths of all tt arrays does not exceed 10610^6.
  • 1ai1091 \leq a_i \leq 10^9
# Points Constraints
1 0 Example
2 14 1n1001 \leq n \leq 100
3 22 1n5 0001 \leq n \leq 5\ 000
4 38 1n100 0001 \leq n \leq 100\ 000
5 26 No additional constraints

Example

stdin

5
10
1 4 7 4 2 4 7 3 2 3 
8
1 2 4 1 5 3 1 2
10
6 8 9 1 8 5 4 6 3 2
6
1 1 1 2 2 2
12
1 5 8 3 2 5 7 4 9 5 7 4

stdout

6
4
4
6
3

Explanation

The subarray 4 7 4 2 4 7 contains 33 distinct numbers. There is no subarray with more than 66 numbers that meets the criteria.

Log in or sign up to be able to send submissions!