# yukicoder import re T = int(input()) for _ in range(T): s = input() D = re.split('\d+', s) E = re.split("[^][0-9]+", s) F = [] while E and E[-1] == "": E.pop() if E: E[-1] = str(int(E[-1])+1).zfill(len(E[-1])) F = [] for some in E: if some != "": F.append(some) ans = "" for _ in range(len(F)): ans += D[_] ans += F[_] ans += D[-1] print(ans)