import sys sys.setrecursionlimit(10000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 def solve(): S = list(input()) first = False for i in range(len(S) - 1,-1,-1): if 0 <= ord(S[i]) - 48 < 10: if 0 <= ord(S[i]) - 48 < 9: S[i] = chr(ord(S[i]) + 1) break else: S[i] = '0' first = True else: if first: S = S[:i + 1] + ['1'] + S[i + 1:] break print(''.join(S)) T = int(input()) for _ in range(T): solve()