#include<time.h>
#include <cstdio>
#include <iostream>
#include<algorithm>
#include<math.h>
#include <string.h>
#include<vector>
#include<queue>
using namespace std;
int d[],a[];
int len,i,k,n,m;
int binary(int t)
{
int low,high,mid;
low=;
high=len;
while(low<high)
{
//mid=low+(high-low)*(num-p[low])/(p[high]-p[low]);//插值排序
mid=(low+high)/;
if(d[mid]<=t)
low=mid+;
else
high=mid;
}
return low;
}
int main()
{
int cas;
cin>>cas;
while(cas--)
{
cin>>n;
for(i=;i<=n;i++)
cin>>a[i];
len=;
d[]=-;
for(i=;i<=n;i++)
{
if(a[i]>d[len])
{
len++;
d[len]=a[i];
//cout<<d[len]<<" ";
}
else
{
k=binary(a[i]);
d[k]=a[i];
}
}
cout<<len<<endl;
if(cas) //这里是个坑
cout<<endl;
}
return ;
}