#include #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)n;++i) #define each(a, b) for(auto (a): (b)) #define all(v) (v).begin(),(v).end() #define fi first #define se second #define pb push_back #define show(x) cout <<#x<<" = "<<(x)<P; const int MAX_N = 100005; int main() { string n; getline(cin,n); int m = stoi(n); rep(i,m){ string s; getline(cin,s); vector vec; int pl=0; int ed=s.size(); int flag = 0; rep(j,s.size()){ if(isdigit(s[j])){ if(flag == 0){ flag++; pl = j; vec.clear(); } vec.pb(s[j]); }else if(flag > 0){ ed = j; flag = 0; } } if(vec.size() == 0){ cout << s << "\n"; continue; } rep(j,pl){ cout << s[j]; } flag = 0; string hoge; rep(j,vec.size()){ if(flag == 0 && vec[j] == '0' && j != (int)vec.size()-1){ cout << '0'; }else{ flag = 1; hoge.pb(vec[j]); } } int hogehoge = stoi(hoge); cout << to_string(hogehoge+1); for(int j=ed;j<(int)s.size();j++){ cout << s[j]; } cout << "\n"; } return 0; }