#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i;
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    n = str.size();
    for (auto &it : str) {
      it -= '0';
    }
    string sol;
    int l1 = 0, r1 = 0;
    while (r1 < n && str[r1] % 2 == str[l1] % 2) {
      r1++;
    }
    r1--;
    int l2 = 0, r2 = -1;
    while (1) {
      if (l1 > r1) {
        while (l1 < n && str[l1] % 2 == str[l2] % 2) {
          l1++;
        }
        r1 = l1;
        while (r1 < n && str[r1] % 2 == str[l1] % 2) {
          r1++;
        }
        r1--;
      }
      if (l2 > r2) {
        while (l2 < n && str[l2] % 2 == str[l1] % 2) {
          l2++;
        }
        r2 = l2;
        while (r2 < n && str[r2] % 2 == str[l2] % 2) {
          r2++;
        }
        r2--;
      }
      if (l1 == n || l2 == n) {
        break;
      }
      if (str[l1] <= str[l2]) {
        sol.push_back(str[l1++] + '0');
      } else {
        sol.push_back(str[l2++] + '0');
      }
    }
    for (i = l1; i < n; i++) {
      if (str[l1] % 2 == str[i] % 2) sol.push_back(str[i] + '0');
    }
    for (i = l2; i < n; i++) {
      if (str[l2] % 2 == str[i] % 2) sol.push_back(str[i] + '0');
    }
    cout << sol << "\n";
  }
  return 0;
}
