G. Speed Sorting
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

ScepticallySam owns a speed packing service that uses robots to process packages.

Each robot is assigned a pair of indices $$$i \le j$$$ and performs the following operations on a line of packages:

  • stamps all packages in the subarray $$$[i, j]$$$;
  • sorts the packages in $$$[i, j]$$$ in ascending order of weight.

A robot cannot move packages outside its assigned subarray.

Each line of packages is represented as an array of integers. For each line, ScepticallySam assigns robots to several non-overlapping subarrays, and all robots operate simultaneously.

After all robots finish, the entire line must be stamped and sorted in ascending order.

Given $$$t$$$ lines of packages, determine the maximum number of robots that can be assigned to each line while satisfying the above conditions.

Note: No robots were harmed in the making of this question.

Input

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) which represents the number of lines of packages.

The first line of the $$$i^{th}$$$ testcase contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$), the number of packages in the line.

The second line of the $$$i^{th}$$$ testcase contains $$$n$$$ integers $$$a_1, a_2, ..., a_n$$$ ($$$1 \le a_i \le 10^9$$$) representing the weight of each package in the line.

It is guaranteed that the sum of $$$n$$$ (The total number of packages) over all the testcases does not exceed $$$2 \cdot 10^5$$$.

Output

For each line of packages, output one integer, which is the maximum number of robots required to completely stamp and sort all the packages in the array.

Example
Input
3
4
1 2 3 4
4
4 3 2 1
5
1 2 3 5 4
Output
4
1
4
Note

In the first testcase, we can allocate 1 robot to each box since it's already sorted. Hence, 4 robots can be used, which is the maximum number of robots that can be used.

In the second testcase, we must allocate 1 robot to the entire sequence. It is not possible to achieve the goal in any other way.

In the third testcase, we can allocate 1 robot to each of the first three boxes and 1 robot to the last two boxes. So 4 robots in total.