local n, m = io.read("*n", "*n") local large = math.floor(n / 2) local small = n - large if m < n - 1 or small * large < m then print("NO") os.exit() end print("YES") for i = 1, n do io.write(i) io.write(i == n and "\n" or " ") end for i = 1, small do if small + i <= n then print(i .. " " .. small + i) end if 1 < i then print(i .. " " .. small + i - 1) end end local rem = m - n + 1 for i = 1, small do if rem == 0 then break end for j = small + 1, n do if rem == 0 then break end if j ~= small + i and j ~= small + i - 1 then print(i .. " " .. j) rem = rem - 1 end end end