#include using namespace std; #define FOR(i, n) for(int i = 0; i < (n); i++) #define MEM(a, x) memset(a, x, sizeof(a)) #define ALL(a) a.begin(), a.end() #define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) typedef long long ll; typedef pair P; int t; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin >> t; cin.ignore(); vector ans(t); FOR(i, t) { string s; getline(cin, s); int n = s.size(), l = -1, r = -1, pos = n-1; while (pos >= 0 && !(s[pos] >= '0' && s[pos] <= '9')) pos--; r = pos; if (r == -1) { ans[i] = s; continue; } while (pos >= 0 && s[pos] >= '0' && s[pos] <= '9') pos--; l = pos + 1; string sub = s.substr(l, r-l+1); int x = atoi(sub.c_str()); string from = to_string(x); x++; string to = to_string(x); if (to.size() > from.size() && sub[0] != '0') { ans[i] = s.substr(0, l) + to + s.substr(r+1); } else { string ret(sub.size()-to.size(), '0'); ret += to; ans[i] = s.substr(0, l) + ret + s.substr(r+1); } } FOR(i, t) cout << ans[i] << endl; return 0; }