import sys def II(): return int(sys.stdin.buffer.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=sys.stdin.buffer.readline()[:-1] n=len(s) for i,c in enumerate(s[::-1]): if c.isdigit(): r=n-i break else: print(s) continue for j,c in enumerate(s[r-1::-1]): if not c.isdigit(): l=n-i-j break else:l=0 print(s[:l]+plus1(s[l:r])+s[r:]) main()