Codeforces
CF Step
Youtube Linkedin Discord Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Statement : Right Maximum

B. Right Maximum

You are given an array a of n integers.

While the array is not empty, an operation is performed:

  1. The maximum element in the array is chosen (if there are multiple, the rightmost maximum is chosen).
  2. All elements at or after the chosen element are removed from the array.

Your task is to calculate how many operations are performed before the array becomes empty.


Input

The first line contains one integer t (1t104) — the number of test cases.

Each test case consists of two lines:

  • The first line contains one integer n (2n2105).
  • The second line contains n integers a1,a2,,an (1ain).

The sum of n over all test cases does not exceed 2105.


Output

For each test case, print one integer — the number of operations performed.


Example

Input

4
5
2 1 2 3 1
6
1 2 3 4 5 6
3
3 2 1
4
1 3 3 1

Output

3
6
1
3

Note

In the first example, array is [2,1,2,3,1]. First operation: rightmost max is at index 4 (value 3), remove from index 4 → [2,1,2]. Second: rightmost max at index 2 (value 2), remove from 2 → [2,1]. Third: rightmost max at index 0, remove all → empty. So 3 operations.