#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9+8
#define OO 1e18
#define EPS 1e-9
#define Endl '\n'
#define all(v) (v).begin(),(v).end()
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

int cnt=1;
int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int tsc;
    cin>>tsc;
    while(tsc--){
       int n;
       cin>>n;
       int a[n];
       for (int i = 0; i < n; ++i)
       {
           cin>>a[i];
       }
       for (int i = 0; i < n; ++i)
       {
           if(a[i]%2==0){cout<<a[i]<<" ";}
       }
       for (int i = 0; i < n; ++i)
       {
           if(a[i]%2==1){cout<<a[i]<<" ";}
       }
       

}
    
}
