import re def solve(s): lastspan = None for mo in re.finditer(r'\d+', s): lastspan=mo.span() if lastspan is None: return s else: b, e = lastspan nu = s[b:e] mo = re.match(r'^(0*)(([1-9][0-9]*)?)$', nu) pad, body = mo.group(1), mo.group(2) if body=='': pad = pad[1:] body = '0' plus = str(int(body)+1) if len(plus) > len(body): if len(pad) > 0: pad = pad[1:] return s[:b] + pad + plus + s[e:] n=int(raw_input().rstrip()) for i in range(n): s=raw_input().rstrip() print solve(s)