#得るものがないのでコピペ  import sys def II(): return int(sys.stdin.readline()) def main(): def plus1(s): n=len(s) num=str(int(s)+1).zfill(n) return num t=II() for _ in range(t): s=input() n=len(s) for r in range(n,0,-1): if s[r-1].isdigit():break else: print(s) continue for l in range(r,0,-1): if not s[l-1].isdigit():break else:l=0 print(s[:l]+plus1(s[l:r])+s[r:]) main()