import re def increment(s): chars = list(s) carry = 1 i = len(chars) - 1 while i >= 0 and carry: digit = int(chars[i]) + carry carry = digit // 10 chars[i] = str(digit % 10) i -= 1 if carry: return str(carry) + ''.join(chars) else: return ''.join(chars) T = int(input()) for _ in range(T): S = input().strip() matches = list(re.finditer(r'\d+', S)) if not matches: print(S) continue last_match = matches[-1] start = last_match.start() end = last_match.end() num_str = last_match.group() new_num = increment(num_str) ans = S[:start] + new_num + S[end:] print(ans)