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

const int NMAX = 1e2;
const int SMAX = 4e4;
const int BITS = 25;

using namespace std;

int dp[NMAX + 5][SMAX + 5];
array<int, 3> bck[NMAX + 5][SMAX + 5];
vector<int> nums[BITS + 5];
int a[NMAX + 5], viz[NMAX + 5], n;
bool preced = false;

void prec() {
    preced = true;
    for (int i = 0; i < (1LL << BITS); ++i)
        nums[__builtin_popcountll(i)].push_back(i);
}

std::vector<int> solve(std::vector<int> A) {
    n = (int)A.size();

    if (!preced)
        prec();

    int S = accumulate(A.begin(), A.end(), 0LL);
    int target = (S + 1) / 2;
    int best = -1, best_dif = INT_MAX;
    for (int cate = 0; cate <= n; ++cate) {
        if (target > nums[cate].back()) continue;

        int marisa = cate;
        int deni = n - cate;
        int dif = abs(marisa - deni);
        if (dif < best_dif) {
            auto it = lower_bound(nums[cate].begin(), nums[cate].end(), target);
            best = *it;
            best_dif = dif;
        }
    }

    vector<int> ans;
    for (int i = 0; i < n; ++i) {
        if ((best & (1LL << i)))
            ans.push_back(i);
    }

    for (int i = 0; i < n; ++i) {
        if (!(best & (1LL << 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