#include #include #include #include #include #include #include #include using namespace std; const int MAX_LENGTH = 100000; int main() { int tests; for (assert(scanf("%d", &tests) == 1 && 1 <= tests && tests <= 10); tests --;) { string s; assert(cin >> s); assert(1 <= s.size() && s.size() <= MAX_LENGTH); assert(s[0] > '0'); vector cnt(10, 0); for (int i = 0; i < s.size(); ++ i) { assert(isdigit(s[i])); ++ cnt[s[i] - '0']; } if (s.size() == MAX_LENGTH) { assert(s[0] == '1'); for (int i = 1; i < s.size(); ++ i) { assert(s[i] == '0'); } } for (char ch = 'A'; ch <= 'Z'; ++ ch) { int a = ch / 10; int b = ch % 10; -- cnt[a]; -- cnt[b]; if (cnt[a] >= 0 && cnt[b] >= 0) { putchar(ch); } ++ cnt[a]; ++ cnt[b]; } puts(""); } return 0; }