#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int arr[N];
char mx(string &s) {
  char res = '0' - 1;
  for (auto c : s) res = max(res, c);
  return res;
}
string merge(string &a, string &b) {
  int i = 0, j = 0;
  string res = "";
  while (i < (int)(a).size() && j < (int)(b).size()) {
    if (a[i] < b[j])
      res += a[i++];
    else
      res += b[j++];
  }
  while (i < (int)(a).size()) res += a[i++];
  while (j < (int)(b).size()) res += b[j++];
  return res;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<string> e, o;
    string t1 = "", t2 = "";
    for (int i = 0; i < (int)(s).size(); ++i) {
      if ((s[i] - 'a') & 1) {
        while (i < (int)(s).size() && ((s[i] - 'a') & 1)) t1 += s[i++];
        --i;
      } else {
        while (i < (int)(s).size() && !((s[i] - 'a') & 1)) t2 += s[i++];
        --i;
      }
    }
    cout << merge(t1, t2) << '\n';
    continue;
    string res = "";
    int i = 0, j = 0;
    while ((int)(res).size() < (int)(s).size()) {
      if (i < (int)(e).size() && j < (int)(o).size()) {
        if (e[i][0] > mx(o[j]))
          res += o[j++];
        else if (o[j][0] > mx(e[i]))
          res += e[i++];
        else
          res += merge(e[i], o[j]), i++, j++;
      } else {
        while (i < (int)(e).size()) res += e[i++];
        while (j < (int)(o).size()) res += o[j++];
      }
    }
    cout << res << '\n';
  }
  return 0;
}
