#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
	// your code goes here
	
	ll t;
	cin>>t;
	
	while(t--)
	{
	    ll n;
	    cin>>n;
	    
	    vector<ll>v,tt;
	    vector<ll>ans;
	    ll codd=0,ceven=0;
	    
	    for(ll i=0;i<n;i++)
	    {
	        ll k;
	        cin>>k;
	        v.push_back(k);
	        
	        if(v[i]%2==0)
	        {
	            ceven++;
	            tt.push_back(v[i]);
	        }
	        
	        else
	        {
	            codd++;
	            ans.push_back(v[i]);
	        }
	    }
	    
	    for(int i=0;i<ceven;i++)
	    {
	        ans.push_back(tt[i]);
	    }
	    
	    if(ceven>codd)
	    reverse(ans.begin(),ans.end());
	    
	    for(ll i=0;i<n;i++)
	    cout<<ans[i]<<" ";
	    
	    cout<<endl;
	    
	    
	}
	
	return 0;
}
