import re T = int(input()) S = [] for i in range(T): S.append(input()) for s in S: pattern = r'\d+' iterator = re.finditer(pattern, s) match = 0 longest = 0 for i in iterator: if len(i.group()) >= longest: match = i longest = len(i.group()) if match == 0: print(s) continue ans = s[:match.start()] ans += ('%0' + str(len(match.group())) + 'd') % (int(match.group()) + 1) ans += s[match.end():] print(ans)