You are given an array of integers. Find the longest increasing subsequence. Formally, remove as few values as possible such that the remaining values form a strictly increasing subsequence, and print the remaining numbers.
Just kidding, who needs this in real life? We are interested in something deeper than that.
Each number has now a favorite value , which even though it can be (according to the normal rules) , is ready to consider that , if this would bring immediately to the right of in the increasing subsequence we consider. As a consequence, alongside the normal comparison rules, we also introduce the relation , without deleting .
Task
Find the longest increasing subsequence, given the new conditions.
Formally, an array is now strictly increasing if for each pair of consecutive values , either or .
Input data
The first line contains the number of tests in the file. For each test, the description is similar: On the first line, the number of numbers in the array. On the next line there are numbers with values between and , representing the array. On the next line there are numbers with values between and , the of which is .
Output data
The first line of each test case will contain the size of the longest maximally increasing substring of the string, considering new rules.
Constraints and clarifications
- For points,
- For other points,
- For other points, ,
- For other points, all values from the array are , or .
- For other points, for every integer there are at most values of such that .
Example
stdin
2
10
4 1 6 1 8 10 10 1 9 1
3 6 3 2 1 9 8 1 5 10
8
8 1 8 6 4 8 5 7
7 3 2 8 8 4 5 6
stdout
5
6
Explanation
In the first test, the maximum sequence is
In the second test, the maximum sequence is