#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e6 + 5;
const ll inf = 1e16;

bool taken[N];
int lg2[1<<20], mx[1<<20];
ll sum[1<<20];

vector<int> solve(vector<int> a) {
    vector<int> ans;
    int n = a.size();
    
    if(!lg2[2]) {
        for(int i=1; i<=20; i++)
            lg2[1<<i] = i;
    }
    ll s = 0;
    for(auto x : a)
        s += x;
    
    int mindiff = n, bstmask = 0; 
    for(int mask=1; mask<(1<<n); mask++) {
        int lsb = (mask & -mask);
        sum[mask] = sum[mask^lsb] + a[lg2[lsb]];
        mx[mask] = max(mx[mask^lsb], a[lg2[lsb]]);

        if(sum[mask] >= s / 2.0 && sum[mask] - mx[mask] < s / 2.0) {
            int bits = __builtin_popcount(mask);
            if(abs(bits-(n-bits)) < mindiff) {
                mindiff = abs(bits-(n-bits));
                bstmask = mask;
            }
        }
    }

    if(!bstmask) {
        for(int i=0; i<n; i++)
            ans.pb(i);
        return ans;
    }

    int bst = -1;
    for(int i=0; i<n; i++)
        if((1 << i) & bstmask)
            if(bst == -1 || a[i] > a[bst])
                bst = i;
    for(int i=0; i<n; i++)
        if(((1 << i) & bstmask) && i != bst)
            ans.pb(i);
    ans.pb(bst);
    for(int i=0; i<n; i++)
        if(!(bstmask & (1 << i)))
            ans.pb(i);
    
    return ans;
}

#ifndef EVAL
int32_t main() {
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
    cin.tie(nullptr)->sync_with_stdio(0);

    int tt;
    cin >> tt;
    while(tt--) {
        vector<int> a;
        int n;
        cin >> n;
        for(int i=1; i<=n; i++) {
            int x;
            cin >> x;
            a.pb(x);
        }
        vector<int> res = solve(a);

        //assert(abs(pax-(n-pax)) <= 1);
        for(auto x : res)
            cout << x << ' ';
        cout << '\n';

    }
    return 0;
}
#endif