#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n,i;
    cin>>t;
    for(i=1;i<=t;i=i+1)
    {
        cin>>n;
        int a[n],j;
        vector<int>vec,vec1;
        vector<int>::iterator it;
        for(j=0;j<n;j=j+1)
        {
            cin>>a[j];
            if(a[j]%2==0)
            {
                vec.push_back(a[j]);
            }
            else if(a[j]%2!=0)
            {
                vec1.push_back(a[j]);
            }
        }
        for(it=vec.begin();it!=vec.end();it++)
        {
            printf("%d ",*it);
        }
        for(it=vec1.begin();it!=vec1.end();it++)
        {
            printf("%d ",*it);
        }
        printf("\n");
    }
}
