#include "bits/stdc++.h" #define rep(a,b) for(int a = 0;a < b;a++) #define REP(i, x, n) for(int i = x; i < n; i++) #define P(a) cout << a << endl using namespace std; typedef long long ll; typedef unsigned long long ull; int dx[] = { 1, -1 , 0 , 0 }; int dy[] = { 0, 0, 1, -1 }; unsigned long long str_to_int(std::string str) { unsigned long long ret; std::stringstream ss; ss << str; ss >> ret; return ret; } int main() { int n; cin >> n; cin.ignore(); vector v(n); rep(i, n) { getline(cin,v[i]); } rep(i, n) { int pos; string num = ""; rep(j, v[i].length()) { if (v[i][j] >= '0' and v[i][j] <= '9') { num = ""; pos = j; while (v[i][j] >= '0' and v[i][j] <= '9') { num = num + v[i][j]; j++; if (j == v[i].length()) { break; } } } } int numlen = num.length(); if (num == "") { P(v[i]); continue; } int j = num.length() - 1; if (num[j] == '9') { while (num[j] == '9') { num[j] = '0'; j--; if (j < 0) { num = '1' + num; break; } } if (j >= 0) { num[j] = num[j] + 1; } } else { num[j] = num[j] + 1; } string ans = ""; rep(j, pos) { ans = ans + v[i][j]; } ans = ans + num; REP(j, pos + numlen, v[i].length()) { ans = ans + v[i][j]; } P(ans); } }