#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back

extern vector<int> solve(vector<int> a){
    int n = a.size();
    vector <pair<int,int> > b(n);

    for(int i = 0;i < n;i++){
        b[i].ff = a[i];
        b[i].ss = i;
    }

    sort(all(b));

    vector <int> ans;

    for(int i = n / 2 ;i < n;i++){
        ans.pb(i);
    }
    for(int i = 0;i < n / 2;i++){
        ans.pb(i);
    }
    return ans;
}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t ;
    for (int test=1; test<=t; test++) {
        int n;
        cin >> n ;
        vector <int> a(n);
        for (int i=0; i<n; i++) {
            cin >> a[i] ;
        }

        vector <int> ans = solve(a);

        for (int i = 0;i < n;i++) {
            cout << ans[i] << ' ';
        }
        cout << endl ;
    }
    cout << endl ;
    return 0;
}
