#include #define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define MOD 1000000007 //#define int long long using namespace std; typedef long long ll; const int INF = 1e9; signed main() { int T; string S; cin >> T; cin.ignore(); REP(i,T) { //cin >> S; getline(cin, S); reverse(S.begin(), S.end()); bool hit = false; REP(j,S.length()) { if ('0' <= S[j] && S[j] <= '8') { S[j] += 1; reverse(S.begin(), S.end()); cout << S << endl; hit = true; break; } else if (S[j] == '9') { //cout << "AAAAAa" << endl; while (S[j] == '9') { S[j] = '0'; j++; } //cout <<"TEST" << S << endl; if ('0' <= S[j] && S[j] <= '8') { S[j]++; reverse(S.begin(), S.end()); cout << S << endl; hit = true; break; } else { string ans = S.substr(0, j) + '1' + S.substr(j); reverse(ans.begin(), ans.end()); cout << ans << endl; hit = true; break; } } } if (!hit) { reverse(S.begin(), S.end()); cout << S << endl; } } }