#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--){ string s, ans, ord = "1234567890"; cin >> s; for(int i = 0; i < (int)s.size(); i++){ for(int j = 0; j < ord.size(); j++){ if(ord[j] == s[i]){ swap(ord[j], ord.back()); break; } } if(i == 0 && ord[i] == '0'){ rotate(ord.begin(), ord.begin() + 1, ord.begin() + 9); } ans += ord; } ans.pop_back(); cout << ans << '\n'; } }