import sequtils,algorithm,strutils template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord proc printf(formatstr: cstring){.header: "", varargs.} proc putchar_unlocked(c:char){. importc:"putchar_unlocked",header: "" .} proc parse(): seq[tuple[str:string,isNum:bool]] = result = @[] var current = "" var isNum = false while true: let k = getchar_unlocked() if k.ord < 32 or k.ord > 126 : result &= (current,isNum) return let kIsNum = k >= '0' and k <= '9' if isNum xor kIsNum and current != "": result &= (current,isNum) current = "" current &= k isNum = kIsNum proc add1(S:string):string = result = "" var ch = 1 for i in (S.len-1).countdown(0): let c = S[i].ord - '0'.ord let d = c + ch if d < 10 : ch = 0 result &= ('0'.ord + d).chr else: ch = 1 result &= ('0'.ord + d mod 10).chr if ch > 0: result &= ('0'.ord + ch).chr result.reverse() scan().times: var P = parse() for i in (P.len()-1).countdown(0): if not P[i].isNum : continue P[i].str = P[i].str.add1() break for i in 0..