#include #include #include #define INF 0x3F3F3F3F #define N_MAX 100000 int T, n, i, a, f, x[N_MAX + 1]; inline int bis(int l, int r, int a) // [l, r] { register int t = 0; for (register int m = (l + r) >> 1; l <= r; m = (l + r) >> 1) if (x[m] >= a) r = m - 1; else t = m, l = m + 1; return t; } int main() { scanf("%d", &T); while (T--) { scanf("%d", &n); memset(x + 1, INF, n * sizeof (int)); for (i = 1; i <= n; ++i) scanf("%d", &a), printf("%d%c", f = bis(1, i - 1, a) + 1, i < n ? ' ' : '\n'), x[f] = std::min(x[f], a); } return 0; }