#include "partition.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;

using ll = long long;
std::vector<int> solve(vector<int>v) {
    int n = v.size();
    ll sum = accumulate(v.begin(),v.end(),0ll);
    vector<int> id(n);
    for(int i = 0; i < n; i++)
        id[i] = i;
    vector<int> res(n);
    int k = (n+1)/2-1;
    ll hl = (sum+1)/2;
    ll ini = 0;
    for(int i = n-k;i < n; i++)
        ini+=v[id[i]];
    for(int i = n-1; i-k >= 0; i--)
    {
        ini-=v[id[i]]-v[id[i-k]];
        if(ini>=hl-v[id[n-1]]&&ini<hl)
        {
            vector<int> vis(n,0);
            for(int j = i-k;j < i;j++)
            {
                res[j-i+k]=id[j];
                vis[id[j]]=1;
            }
            res[k]=id[n-1];
            vis[id[n-1]]=1;
            int cr = 0;
            for(int j = k+1;j<n;j++)
            {
                while(vis[cr])cr++;
                vis[cr] = 1;
                res[j]=cr;
            }
            break;
        }
    }
    assert(ini+v[id[n-1]]>=hl);
    return res;
}

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] ;
        }

        for (auto ind : solve(a)) {
            cout << ind << " ";
        }
        cout << endl ;
    }
    cout << endl ;
    return 0;
}
