#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int a[100000],f[100000],d[100000]; int bs(const int *f,int s,const int &a) { int l=0,r=s-1,mid; while(l<=r) { mid=(l+r)/2; if(a>f[mid-1]&&a<=f[mid]) return mid; else if(af[s-1]) j=s++; else j=bs(f,s,a[i]); f[j]=a[i]; d[i]=j+1; } return s; } int main() { int T,n; while(scanf("%d",&T)!=EOF) { while(T--) { memset(f,0,sizeof(f)); memset(d,0,sizeof(d)); scanf("%d",&n); for(int i=0;i