#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <string.h>
#include <math.h>
#include <stack>
#include <ctype.h>
using namespace std;
int k,n;
int dp1[105];
int dp2[105];
int height[105];
int main()
{
cin >> k;
while( k-- )
{
memset(dp1, 0, sizeof(dp1));
memset(dp2, 0, sizeof(dp2));
memset(height, 0, sizeof(height));
cin >> n;
for(int i = 1; i <= n; i++ )
{
cin >> height[i];
dp1[i] = 1;
dp2[i] = 1;
}
for( int i = 2; i <= n; i++ )
{
int Max = 0;
for( int j = 1; j <= i-1; j++ )
{
if( Max < dp1[j] && height[i] > height[j] )
{
Max = dp1[j];
}
}
dp1[i] = Max + 1;
}
for( int i = 2; i <= n; i++ )
{
int Max = 0;
for( int j = 1; j <= i-1; j++ )
{
if( Max < dp2[j] && height[i] < height[j] )
{
Max = dp2[j];
}
}
dp2[i] = Max + 1;
}
int ans = 0;
for( int i = 1; i <= n; i++ )
{
ans = max(ans, dp1[i]);
ans = max(ans, dp2[i]);
}
cout << ans <<endl;
}
return 0;
}
最长上升子序列和最长下降子序列