# Alan Turing is standing on a tape divided into cells that is infinite in both directions.

Cells are numbered with consecutive integers from left to right. Alan is initially standing in cell 00. Every cell xx has cell x1x−1 on the left and cell x+1x+1 on the right.

Each cell can either contain an integer or be empty. Initially all cells are empty.

Alan is given a permutation a1,a2,,ana1,a2,…,an of integers from 11 to nn that was chosen uniformly at random among all permutations of length nn.

At time 11, integer a1a1 is written down into cell 00 where Alan is located.

At each time ii from 22 to nn inclusive, the following happens. First, Alan decides whether to stay in the same cell he’s currently in, move to the neighboring cell on the left, or move to the neighboring cell on the right. After that, integer aiai is written down into the cell where Alan is located. If that cell already contained some integer, the old integer is overwritten and irrelevant from that moment on.

Once anan is written down into some cell at time nn, sequence bb of all integers contained in the cells from left to right is formed. Empty cells are ignored.

Turing’s award is equal to the length of the longest increasing subsequence of sequence bb.

Help Alan and determine the largest possible value of his award if he acts optimally.

Input Turing’s Award solution codeforces

Each test contains multiple test cases. The first line contains the number of test cases tt (1t10001≤t≤1000). Description of the test cases follows.

Each test case is given in two lines. The first line of each test case contains a single integer nn (2n150002≤n≤15000) — the length of the permutation given to Alan.

The second line contains nn distinct integers a1,a2,,ana1,a2,…,an (1ain1≤ai≤n) — the elements of the permutation.

It is guaranteed that the permutation was chosen uniformly at random among all permutations of the corresponding length.

The sum of nn over all test cases does not exceed 1500015000.

Output Turing’s Award solution codeforces

For each test case output a single integer — the largest possible value of Turing’s award.

Hacks are not allowed for this problem.

Example

input

Copy
4
2
1 2
4
4 1 2 3
7
3 6 5 7 4 1 2
7
5 2 3 7 6 1 4


output

Copy
2
3
4
4

Note Turing’s Award solution codeforces

Longest increasing subsequence of sequence bb is the longest increasing sequence that can be obtained from bb by deletion of several (possibly, zero or all) elements.

In the first test case, Alan can make a decision only at time 22. If Alan stays in cell 00, sequence bb will be equal to [2][2]. If Alan moves to the left, to cell 1−1, sequence bb will be equal to [2,1][2,1]. If Alan moves to the right, to cell 11, sequence bb will be equal to [1,2][1,2]. Only in the last case the length of the longest increasing subsequence of bb is 22, therefore, the answer is equal to 22.

In the second test case, one of the optimal sequences of actions looks as follows: move to the left at times 22 and 33, and move to the right at time 44. Then sequence bb will be equal to [2,3,4][2,3,4], and the length of its longest increasing subsequence is 33.

In the third test case, one of the best ways is to always move to the left. Then sequence bb will be equal to [2,1,4,7,5,6,3][2,1,4,7,5,6,3], and the length of its longest increasing subsequence is 44.

In the fourth test case, one of the best ways is to move to the right four times, then move to the left once, and stay in the same cell once. Sequence bb will be equal to [5,2,3,4,6][5,2,3,4,6].

## COMING SOON

Also read : Wafa Na Raas Aayi Lyrics