/** */ #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; const int inf = 0x3f3f3f3f; const int maxn = 1e5+100; int n, m; int a[maxn], f[maxn], b[maxn]; int main() { int T; cin>>T; while(T--) { scanf("%d",&n); for(int i = 0; i < n; i++){ scanf("%d",&a[i]); } fill(b,b+n+1,inf); for(int i = 0; i < n; i++){ int k = lower_bound(b,b+n,a[i])-b; f[i] = k+1; b[k] = a[i]; } for(int i = 0; i < n-1; i++){ printf("%d ",f[i]); } printf("%d\n",f[n-1]); } return 0; }