#include #include #include #include using namespace std; const int maxn = 1e5 + 10; int n, tmp; int dp[maxn]; int main() { int t; scanf("%d", &t); while(t--) { int val = 0; scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%d", &tmp); int pos = lower_bound(dp, dp + val, tmp) - dp; if(pos == val) dp[val++] = tmp; else dp[pos] = tmp; if(i == 1) printf("%d", pos + 1); else printf(" %d", pos + 1); }puts(""); } }