local ffi = require 'ffi' for _=1,tonumber(io.stdin:read("*l")) do local s=io.stdin:read("*l") local t,j=ffi.new("int8_t[?]", #s+1, s),-1 for i=#s-1,0,-1 do if t[i]>=48 and t[i]<=57 then t[i]=t[i]+1 if t[i]<=57 then break else t[i]=48 end if i==0 or t[i-1]<48 or t[i-1]>57 then j=i break end end end if j<0 then print(ffi.string(t)) else local t=ffi.string(t) print(t:sub(1,j).."1"..t:sub(j+1)) end end