#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% T = int(readline()) query = readlines() # %% def solve_query(S): S = list(S.rstrip().decode()) S.reverse() S.append('$') # sentinel L = len(S) find = False for i in range(L): x = S[i] if not x.isdigit(): if find: S.insert(i, '1') break continue find = True if x == '9': S[i] = '0' continue S[i] = str(int(x) + 1) break return ''.join(reversed(S[:-1])) # %% for word in query: print(solve_query(word))