#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 300010;
int T, n;
char a[MAXN];
int b[MAXN], vis[MAXN], ans[MAXN];
int l, r, top;
int main() {
  T = read();
  while (T--) {
    scanf("%s", a + 1);
    l = 1, r = 1;
    top = 0;
    n = strlen(a + 1);
    for (int i = 1; i <= n; ++i) b[i] = a[i] - '0';
    int flag = 1;
    memset(vis, 0, sizeof(vis));
    while (top < n) {
      while (vis[flag]) ++flag;
      if (b[flag] & 1) {
        while (r <= n && (r <= flag || (b[r] & 1))) ++r;
        if (r <= n && b[r] <= b[flag]) {
          ans[++top] = b[r];
          vis[r] = 1;
          ++r;
          continue;
        } else {
          ans[++top] = b[flag];
          vis[flag] = 1;
          ++flag;
          continue;
        }
      } else {
        while (l <= n && (l <= flag || !(b[l] & 1))) ++l;
        if (l <= n && b[l] <= b[flag]) {
          ans[++top] = b[l];
          vis[l] = 1;
          ++l;
          continue;
        } else {
          ans[++top] = b[flag];
          vis[flag] = 1;
          ++flag;
          continue;
        }
      }
    }
    for (int i = 1; i <= top; ++i) printf("%d", ans[i]);
    puts("");
  }
}
