#include typedef long long ll; using namespace std; int INF = 1e9; int MOD = 1e9+7; main(){ int N; cin >> N; cin.ignore(); string s; for(int j = 0;j < N;j++){ int numsize = 0,zflag = 0; getline(cin,s); for(int i = s.length()-1;i >= 0;i--){ if(s[i] >= '0' && s[i] <= '9'){ if(numsize == 0 && s[i] == '0'){ s[i] = '1'; break; } if(s[i] == '0') zflag = 1; else{ numsize++; continue; } } if(numsize){ string first,second,numstr; first = s.substr(0,i+1); second = s.substr(i+numsize+1,s.length()-numsize-i-1); int num = stoi(s.substr(i+1,numsize))+1; if(zflag && (int)log10(num) != (int)log10(num-1))first.erase(first.end()); stringstream ss; ss << num; numstr = ss.str(); s = first + numstr + second; break; } } cout << s << endl; } }