#include <bits/stdc++.h>
#include "partition.h"

const int NMAX = 1e2;
const int SMAX = 4000;

using namespace std;

int dp[NMAX + 5][SMAX + 5];
array<int, 3> bck[NMAX + 5][SMAX + 5];

int n;

std::vector<int> solve(std::vector<int> A) {
    n = A.size();
    int S = accumulate(A.begin(), A.end(), 0);
    int target = (S + 1) / 2;

    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int used = 0; used <= i - 1; ++used) {
            for (int sum = 0; sum <= target - 1; ++sum) {
                int new_sum = sum + A[i];
                if (!dp[used + 1][new_sum] && dp[used][sum]) {
                    dp[used + 1][new_sum] |= dp[used][sum];
                    bck[used + 1][new_sum] = {used, sum, i};
                }
            }
        }
    }

    int best_dif = INT_MAX;
    pair<int, int> unde;
    for (int cate = 1; cate <= n; ++cate) {
        for (int sum = target; sum <= S; ++sum) {
            int oth = n - cate;
            int dif = abs(cate - oth);
            if (dp[cate][sum] && dif < best_dif) {
                unde = {cate, sum};
                best_dif = dif;
            }
        }
    }

    vector<int> viz(n, 0);
    vector<int> ans;
    while (unde.first > 0) {
        auto [new_used, new_sum, pos] = bck[unde.first][unde.second];
        unde.first = new_used;
        unde.second = new_sum;
        ans.push_back(pos);
        viz[pos] = true;
    }

    for (int i = 0; i < n; ++i) {
        if (!viz[i])
            ans.push_back(i);
    }

    return ans;
}

#ifndef EVAL
#include<iostream>
#include<vector>
using namespace std;
extern vector<int> solve(vector<int> A);
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;
}
#endif