#include <bits/stdc++.h>

using namespace std;

#define NN 2010
int a[NN], x[NN], id[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in ","r ",stdin);
	freopen("out.out ","w ",stdout);
#endif

	ios_base :: sync_with_stdio(0);
  	cin.tie(0); cout.tie(0);
	
	int T;
	cin >> T;
	
	while (T--) {
		int n;
		cin >> n;
		
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			x[i] = (a[i] & 1);
			id[i] = i;
		}
		sort(id + 1, id + n + 1, [&] (int i, int j) {
			return x[i] < x[j];	
		});
		for (int i = 1; i <= n; i++) cout << a[id[i]] << ' ';
		cout << endl;
	}
	return 0;
}
                   