#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); string solve() { string s; getline(cin, s); vector vs; for (int i = 0; i < s.length(); ) { int j = i; while (j < s.length() && isdigit(s[j]) == isdigit(s[i])) ++j; vs.push_back(s.substr(i, j-i)); i = j; } int p = -1; for (int i = vs.size()-1; i >= 0; i--) { if (isdigit(vs[i][0])) { p = i; break; } } if (p == -1) return s; string &x = vs[p]; x.back()++; for (int i = x.length()-1; i > 0; i--) { if (x[i] > '9') { x[i] = '0'; x[i-1]++; } } if (x[0] > '9') { x[0] = '0'; x = "1" + x; } string ret; for (string x: vs) ret += x; return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int T; cin >> T; string blank; getline(cin, blank); while (T--) { cout << solve() << endl; } return 0; }