isok = true for i = 1, 2 do s = io.read() n = string.len(s) if(n <= 5) then if(s ~= "0") then for j = 1, n do ss = string.sub(s, j, j) if(j == 1) then if(string.match(ss, "[1-9]") == nil) then isok = false end else if(string.match(ss, "[0-9]") == nil) then isok = false end end end if(isok) then snum = tonumber(s) if(12345 < snum) then isok = false end end end else isok = false end end if(isok) then print("OK") else print("NG") end