#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<> typedef long long ll; using namespace std; const ll mod= 1e9+7; int main(){ int N; cin>>N; cin.ignore(); REP(i,0,N){ string s; getline(cin,s); int now=1; bool ok=false; RREP(i,0,s.size()){ if(isdigit(s[i])){ now+=s[i]-'0'; s[i]='0'+now%10; now/=10; ok=true; } else if(now>0&&ok){ s.insert(i+1, 1, '0'+now); break; } } p(s); } return 0; }