def ren_number_count(s,startpoint): count_ren=0 p_break=0 for i in range(startpoint+1): for k in range(10): if s[startpoint-i]==str(k): count_ren+=1 break else: p_break=1 if p_break==1: break return count_ren def nine_number_count(s,startpoint): count_nine=0 for i in range(startpoint+1): if s[startpoint-i]==str(9): count_nine+=1 else: break return count_nine n=int(input()) for i in range(n): count=0 s=input() for j in range(len(s)): for k in range(10): if s[len(s)-1-j]==str(k) and count==0: count=1 if k!=9: ss=list(s) ss[len(s)-1-j]=str(k+1) print("".join(ss)) elif len(s)-1-j==0: ss=list(s) ss[len(s)-1-j]=str(k+1) print("".join(ss)) else: # print(s) ren=ren_number_count(s,len(s)-1-j) nine=nine_number_count(s,len(s)-1-j) ss=list(s) if ren==nine: for l in range(nine): ss[len(s)-1-j-l]=str(0) ss[len(s)-1-j-l]=str(10) print("".join(ss)) else: for l in range(nine): ss[len(s)-1-j-l]=str(0) ss[len(s)-1-j-l-1]=str(int(ss[len(s)-1-j-l-1])+1) print("".join(ss)) # print(ren_number_count(s,len(s)-1-j)) # print(nine_number_count(s,len(s)-1-j)) break