#include <bits/stdc++.h>

using namespace std;

void solve(){
    int n, x;

    cin >> n;

    vector <int> ev, od;

    for(int i = 1; i <= n; i++){
        cin >> x;

        if(x % 2 == 0)
            ev.push_back(x);
        else
            od.push_back(x);
    }

    for(auto it : ev)
        cout << it << " ";
    for(auto it : od)
        cout << it << " ";

    cout << "\n";
}

int main()
{
    int t;

    cin >> t;

    while(t--)
        solve();

    return 0;
}
