local n = io.read("*n", "*l") local str, sstr, pre, suf = "", "", "", "" for i = 1, n do pre, suf = "", "" str = io.read() sstr = str:match("%d+") if(sstr ~= nil and str ~= sstr) then pre, sstr, suf = string.match(str, "(.*[^%d])(%d+)(.-)$") end if sstr == nil then print(str) else local len = #sstr local nums = {} for j = 1, len do table.insert(nums, tonumber(sstr:sub(j, j))) end for j = len, 1, -1 do nums[j] = nums[j] + 1 if nums[j] <= 9 then break else if j ~= 1 then nums[j] = 0 end end end io.write(pre) for j = 1, len do io.write(nums[j]) end io.write(suf .. "\n") end end