#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define REP(i,n) for(ll i=0; i=0; --i) #define REPS(i,n,s) for(ll i=0; i=0; i-=s) #define FOR(i,a,n) for(ll i=a; i=a; --i) #define FORS(i,a,n,s) for(ll i=a; i=a; i-=s) #define VDOUT(x) cerr << #x << "\n";for(auto i : x ) cerr << " " << i << "\n"; #define DOUT(x) cerr << #x << " = " << x << "\n"; #define COUT(x) cout << x << "\n"; #define COUT2(x,y) cout <> n; cin.ignore(); string num, txt_s, txt_e; REP(loop,n) { string s; getline(cin, s); vector vs; REPS(keta, s.length(), 1000) { int sz = s.length() > keta + 1000 ? keta + 1000 : s.length(); vs.push_back(s.substr(keta, sz)); } REPR(i, vs.size()-1) { num = ""; txt_s = ""; txt_e = ""; REPR(er, vs[i].length() - 1) { if (vs[i][er] >= '0' && vs[i][er] <= '9') { num = vs[i][er] + num; } else if (num != "") { txt_s = vs[i].substr(0, er + 1); break; } else { txt_e = vs[i][er] + txt_e; } } bool flag = true; if (num != "") { string tnum = to_string(stoull(num) + 1); int c = num.length() - tnum.length(); REP(k, c) { tnum = "0" + tnum; } if (num.length() < tnum.length())flag = false; num = tnum; } vs[i] = txt_s + num + txt_e; if (txt_s != "" || !flag) break; } REP(i, vs.size()) { cout << vs[i]; } cout << "\n"; } return 0; }