#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int verify(vector<int> A, vector<int> perm, ll sum)
{
    int k=0, n=A.size();
    ll acc = 0;
    while (k<n && acc<((float)sum/2.0))
    {
        acc+=A[perm[k++]];
    }
    return abs(n-2*k);
}

vector<int> brute(vector<int> A)
{
    int n = A.size();
    vector<int> B;
    for (int i = 0; i < n; i++)
    {
        B.push_back(i);
    }
    ll sum = accumulate(A.begin(), A.end(), 0ll);
    vector<int> best;
    int mini = n;
    do
    {
        int k = verify(A, B, sum);
        if (k< mini)
        {
            mini = k;
            best = B;
        }
    } while (next_permutation(B.begin(), B.end()));
    return best;
}
int n;
ll total;
vector<pair<int,int>> C;
vector<vector<vector<int>>> dpt;
int dp(int i, ll sum, int k)
{
    if (sum*2 >= total) return abs(n-2*k);
    if (i==n) return INT_MAX;
    if (dpt[i][sum][k] != -1) return dpt[i][sum][k];
    int ans = min(dp(i+1, sum+C[i].first, k+1), dp(i+1, sum, k));
    return dpt[i][sum][k] = ans;
}

vector<int> solve(vector<int> A)
{
    n = A.size();
    C.clear();
    for (int i = 0; i < n; i++)
    {
        C.push_back({A[i], i});
    }
    sort(C.begin(), C.end());
    total = accumulate(A.begin(), A.end(), 0ll);
    dpt = vector<vector<vector<int>>>(n, vector<vector<int>>(total, vector<int>(n, -1)));
    dp(0, 0, 0);
    vector<int> ans;
    int i=0, sum=0, k=0;
    set<int> inserted;
    while (sum*2<total)
    {
        if ((i==n-1 && 2*(sum+C[i].first) >= total) || dpt[i+1][sum+C[i].first][k+1] == dpt[i][sum][k])
        {
            ans.push_back(C[i].second);
            inserted.insert(C[i].second);
            sum+=C[i].first;
            i++;
            k++;
        }
        else
        {
            i++;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (inserted.find(i)==inserted.end()) ans.push_back(i);
    }
    return ans;
}

#ifdef DEBUG
void stress()
{
    int q = 5000;
    int seed = 14;
    srand(seed);
    int n = 7;
    while (q--)
    {
        vector<int> A(n);
        for (auto &a : A) a = 1<<(rand()%10);
        ll sum = accumulate(A.begin(), A.end(), 0ll);
        auto ans1 = brute(A);
        auto ans2 = solve(A);
        if (verify(A, ans1, sum) < verify(A, ans2, sum))
        {
            for (auto a : A) cout << a << ' ';
            cout << endl;
            for (auto a : ans1) cout << a << ' ';
            cout << endl;
            for (auto a : ans2) cout << a << ' ';
            cout << endl;
            cout << endl;
        }
    }
}

int main () {
    // stress();
    // return 0;
    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;
}
#endif
