#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define eps 0.000000001 #define LONG_INF 10000000000000000 #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) int main() { int t; cin >> t; string alpha; getline(cin, alpha); REP(test_case, t) { string s; getline(cin, s); string change; int touch = -1; for (int i = s.length() - 1;i >= 0;--i) { if (change.length() != 0) { if (s[i] >= '0'&&s[i] <= '9') { touch = i; change.push_back(s[i]); } else { break; } } else { if (s[i] >= '0' && s[i] <= '9') { touch = i; change.push_back(s[i]); } } } if (touch == -1) { cout << s << endl; goto ok; } reverse(change.begin(), change.end()); for (int i = change.length() - 1;i >= 0;--i) { if (change[i] == '9') { change[i] = '0'; if (i == 0) change = "1" + change; } else { change[i] += 1; break; } } for (int i = 0;i < touch;++i) { cout << s[i]; } cout << change; for (int i = s.length() - 1;i >= 0;--i) { if (s[i] >= '0' && s[i] <= '9') { for (int q = i + 1;q < s.length();++q) { cout << s[q]; } break; } } cout << endl; ok:; } return 0; }