def partsolve2(l): l = list(l) addone = False started = False n = 0 for i, c in enumerate(l[::-1]): n = i if 0x30 <= ord(c) <= 0x38: l[len(l) - i - 1] = chr(ord(c) + 1) addone = False break elif ord(c) == 0x39: l[len(l) - i - 1] = "0" addone = True started = True else: if addone: l.insert(len(l) - i, "1") addone = False if started: break if addone: l.insert(len(l) - n - 1, "1") return "".join(l) def solve(N, lines): ret = [] for l in lines: ret.append(partsolve2(l)) return ret