#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; void inc(string S){ bool leading_zero = false; if(S[0]=='0') leading_zero = true; int up = 1; for(int i=S.size()-1; i>=0; i--){ int v = up + (int)(S[i]-'0'); up = v/10; S[i] = (char)('0' + v%10); } if(leading_zero){ cout << S; }else{ if(up > 0) cout << up << S; else cout << S; } } void solve(const string& S){ int s = -1, t = -1; for(int i=S.size()-1; i>=0; i--){ if('0'<=S[i] && S[i]<='9'){ if(t == -1){ t = i; s = i; }else{ s = i; } }else{ if(t == -1) continue; else break; } } if(s == -1){ cout << S << endl; }else{ cout << S.substr(0,s); inc(S.substr(s,t+1-s)); cout << S.substr(t+1) << endl; } } int main(){ int T; cin >> T; string S; getline(cin, S); rep(t,T){ getline(cin, S); solve(S); } return 0; }