#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,a,b) for(auto i = a; i <= b; i++)
#define rrep(i,a,b) for(auto i = a; i >= b; i--)

void solve(){
    int n;
    cin >> n;
    vector<int> v0;
    vector<int> v1;
    int x;
    rep(i,0,n-1){
        cin >> x;
        if(x%2==0){
            v0.push_back(x);
        }
        else{
            v1.push_back(x);
        }
    }
    x = 0;
    for(auto it = v0.begin(); it!=v0.end(); it++){
        cout << *it << " ";
    }
    for(auto it = v1.begin(); it!=v1.end(); it++){
        cout << *it << " ";
    }
    cout << "\n";   
    return;
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    int t = 1;
    cin >> t;
    for(int i = 0; i < t; i++){
        solve();
    }
    return 0;
}