#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; int main(){ int t; cin >> t; while(t--){ string s; bool one = false; int idx = -1; getline(cin,s); for(int i=s.size()-1;i>=0;i--){ if('0' <= s[i] && s[i] <= '9'){ if(one){ if(s[i]=='9'){ s[i] = '0'; continue; }else{ s[i] ++; one = false; break; } }else{ if(s[i]=='9'){ s[i] = '0'; one = true; continue; }else{ s[i] ++; one = false; break; } } }else if(one){ idx = i; one = false; break; } } if(one){ s = "1" + s; } if(idx >= 0){ s = s.substr(0,idx+1) + "1" + s.substr(idx+1); } cout << s << endl; } return 0; }