#include using namespace std; string S; void solve() { getline(cin, S); bool f = false; for (auto c : S) f |= isdigit(c); if (!f) { cout << S << endl; return; } bool kr = true; for (int i = S.size()-1; i >= 0; i--) { char c = S[i]; if (isdigit(c)) { while (1) { char &n = S[i]; if (isdigit(n) && kr) n++; if (n == 10 + '0') { n = '0'; } else if (isdigit(n)) { kr = false; } i--; if (i == -1 || !isdigit(n)) { if (kr) { S = S.substr(0, i+2) + '1' + S.substr(i+2); } break; }; } break; } } cout << S << endl; } int main() { int T; cin >> T; getline(cin, S); while (T--) { solve(); } }