#include <iostream>
#include <algorithm>
using namespace std;

void solve(int a[],int n){
    int j=0;
    int k=n-1;
    int b[n];
    for (int i = 0; i < n; i++){
        if((a[i])%2==0){
            b[j++]=a[i];
        }else{
            b[k--]=a[i];
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout<<b[i]<<" ";
    }
    cout<<"\n";
}


int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin>>a[i];
        }
        solve(a,n);
    }
    return 0;
}