import re n = int(input()) for i in range(n): s = input() m = re.search(r'(.*[^0-9]+|)([0-9]+)([^0-9]*)',s) if m is None: print(s) else: print(m.group(1) + str(int(m.group(2)) + 1).zfill(len(m.group(2))) + m.group(3))