import re T = int(input()) regex = re.compile(r'([0-9]+)([^0-9]*$)') d = {str(x): str((x + 1) % 10) for x in range(10)} def func(m): num_str = m.group(1) new_num_list = list(num_str) flag = True for i, s in enumerate(num_str[::-1], 1): new_num_list[-i] = d[new_num_list[-i]] # 繰り上がり判定 if s != '9': flag = False break new_num_str = ''.join(map(str, new_num_list)) if flag: new_num_str = '1' + new_num_str return new_num_str.zfill(len(num_str)) + m.group(2) for _ in range(T): print(regex.sub(func, input()))