#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2) #define MP(a,b) make_pair(a,b) #define PB(a) push_back(a) typedef long long ll; typedef pair pii; const double eps = 1e-8; const int INF = (1 << 30) - 1; const int MAXN = 100010; int T,n; int A[MAXN],B[MAXN],dp[MAXN]; int C[MAXN]; void Add(int x,int d){ while(x <= n){ C[x] = max(C[x],d); x += x & (-x); } } int Get(int x){ int res = 0; while(x){ res = max(res,C[x]); x -= x & (-x); } return res; } int main(){ scanf("%d",&T); while(T--){ scanf("%d",&n); for(int i = 1; i <= n; ++i){ scanf("%d",&A[i]); B[i] = A[i]; } sort(B + 1,B + n + 1); int sz = unique(B + 1,B + n + 1) - B - 1; for(int i = 1; i <= n; ++i){ A[i] = lower_bound(B + 1,B + sz + 1,A[i]) - B; } memset(C,0,sizeof(C)); for(int i = 1; i <= n; ++i){ dp[i] = 1; int res = Get(A[i] - 1); dp[i] = max(dp[i],res + 1); Add(A[i],dp[i]); } for(int i = 1; i <= n; ++i){ printf("%d",dp[i]); if(i < n) printf(" "); else printf("\n"); } } return 0; }