#include #include #include #include #include #include #include #include #include #include #include using namespace std; const int INF = 0x3f3f3f3f; typedef long long ll; const int N = 1e5 + 100; int Lis[N], res[N], vis[N]; int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); #endif int cas; scanf("%d", &cas); while(cas -- ) { int n; scanf("%d", &n); int x, len = 0; Lis[0] = INF; for(int i = 1; i <= n; ++i) { scanf("%d", &x); *lower_bound(Lis, Lis + len, x) = x; int p = lower_bound(Lis, Lis + len, x) - Lis; res[i] = p + 1; if(Lis[len] != INF) Lis[++len] = INF; } for(int i = 1; i <= n; ++i) { if(i > 1) printf(" "); printf("%d", res[i]); }puts(""); } return 0; }