import string def inc(s): carry = len(s) > 0 ret = "" for c in s[::-1]: if not carry: ret += c elif c == '9': ret += '0' else: ret += str(int(c) + 1) carry = False if carry: ret += '1' return ret[::-1] n = int(input()) for j in range(n): s = input() l = 0 r = -1 digit = False for i,c in enumerate(s): if c in string.digits: r = i if not digit: l = i digit = True else: digit = False print(s[:l] + inc(s[l:r+1]) + s[r+1:])