#include #include using namespace std; int main(){ int t; scanf("%d\n", &t); while(t-- > 0){ string s; getline(cin, s); string res = ""; bool number = false; for(int i = s.length()-1; i >= 0; i--){ if(!number && isdigit(s[i])){ int carry = 1; while(i >= 0 && isdigit(s[i])){ int val = carry + (s[i] - '0'); carry = val/10; val %= 10; char next = '0' + val; string t{next}; res = t + res; i--; } i++; if(carry) res = "1" + res; number = true; }else{ res = s.substr(i,1) + res; } } cout << res << endl; } return 0; }