#include <bits/stdc++.h>
using namespace std;
#define Samurai ios_base::sync_with_stdio(false), cout.tie(NULL), cin.tie(NULL);
int main(){ Samurai
int _t = 1;
cin >> _t;
for (int i = 1; i <= _t; i++){
string s; cin >> s;
for(int i = 1; i<s.size(); i++){
for(int j = i; j > 0; j--){
if(s[j]-1 > s[j-1]){
s[j]--;
swap(s[j],s[j-1]);
} else break;
}
}
cout << s << '\n';
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgU2FtdXJhaSBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKSwgY291dC50aWUoTlVMTCksIGNpbi50aWUoTlVMTCk7CmludCBtYWluKCl7IFNhbXVyYWkKICAgIGludCBfdCA9IDE7CiAgICBjaW4gPj4gX3Q7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBfdDsgaSsrKXsKICAgICAgICBzdHJpbmcgczsgY2luID4+IHM7CiAgICAgICAgZm9yKGludCBpID0gMTsgaTxzLnNpemUoKTsgaSsrKXsKICAgICAgICAgICAgZm9yKGludCBqID0gaTsgaiA+IDA7IGotLSl7CiAgICAgICAgICAgICAgICBpZihzW2pdLTEgPiBzW2otMV0pewogICAgICAgICAgICAgICAgICAgIHNbal0tLTsKICAgICAgICAgICAgICAgICAgICBzd2FwKHNbal0sc1tqLTFdKTsKICAgICAgICAgICAgICAgIH0gZWxzZSBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb3V0IDw8IHMgPDwgJ1xuJzsKICAgIH0KICAgIHJldHVybiAwOwp9Cgo=