#include using namespace std; void solve() { string s; getline(cin, s); reverse(s.begin(), s.end()); bool f = false; for (int i = 0; i < s.size(); i++) { if (isdigit(s[i])) { if (s[i] == '9') { s[i] = '0'; f = true; } else { s[i]++; break; } } else if (f) { s.insert(i, "1"); break; } } reverse(s.begin(), s.end()); cout << s << endl; } int main() { int T; cin >> T; cin.ignore(); while (T--) { solve(); } }