#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair <int, int>
#define ld long double
#define ins insert
#define pb push_back
using namespace std;

const int N = 2e5 + 5;
const ll inf = 1e13;

std::vector<int> solve(std::vector<int> A)
{
    vector <pii> a;
    int n = A.size(), s = 0;
    for (auto to: A)
    {
        s += to;
        a.pb({to, a.size()});
    }
    sort(a.begin(), a.end());
    int nd = 0;
    for (int i = 0; i < (n + 1) / 2; i++) nd += a[i].F;
    nd = (s + 1) / 2 - nd;
    if (nd > 0)
    {
        vector <pii> v;
        for (int i = (n + 1) / 2; i < n; i++) v.pb({i, 0});
        reverse(v.begin(), v.end());
        int j = 0;
        for (int i = (n + 1) / 2 - 2; i >= 0; i--)
        {
            while (j < v.size() && (v[j].S == 1 || (a[v[j].F].F > a[i].F && nd - (a[v[j].F].F - a[i].F) < 0))) j++;
            if (j >= v.size()) break;
            if (a[v[j].F].F <= a[i].F) continue;
            nd -= (a[v[j].F].F - a[i].F);
            swap(a[i], a[v[j].F]);
            v.pb(v[j]);
            v[j].S = 1;
        }
        if (nd > 0)
        {
            int mx = (n + 1) / 2 - 1;
            for (auto to: v) if (!to.S && a[to.F].F > a[mx].F) mx = to.F;
            swap(a[(n + 1) / 2 - 1], a[mx]);
        }
    }
    vector <int> B;
    for (auto to: a) B.pb(to.S);
    return B;
}

int32_t main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector <int> a;
        for (int i = 1; i <= n; i++)
        {
            int v;
            cin >> v;
            a.pb(v);
        }
        vector <int> ans = solve(a);
        for (auto to: ans) cout << to << ' ';
        cout << endl;

    }
    return 0;
}
