local mma, mmi = math.max, math.min
local msq = math.sqrt
local n, k = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = {io.read("*n", "*n", "*n")}
end

local function func(x, y)
  local q = {}
  for i = 1, n do
    q[i] = t[i][3] * t[i][3] * ((t[i][1] - x) * (t[i][1] - x) + (t[i][2] - y) * (t[i][2] - y))
  end
  table.sort(q)
  return msq(q[k])
end

local function solve(tbl)
  local xmin, xmax, ymin, ymax = tbl[1], tbl[2], tbl[3], tbl[4]
  local dv = 96
  local dxrange = (xmax - xmin) / (dv * 2)
  local dyrange = (ymax - ymin) / (dv * 2)
  local mpx, mpy, minval = false, false, 0
  for i = 1, dv do
    local xp = xmin + dxrange * (i * 2 - 1)
    yp = ymin - dyrange
    for j = 1, dv do
      yp = yp + dyrange * 2
      local v = func(xp, yp)
      if not mpx or v < minval then
        minval = v
        mpx, mpy = i, j
      end
    end
  end
  tbl[1] = xmin + mma(0, dxrange * (mpx * 2 - 1 - dv / 2))
  tbl[2] = mmi(xmax, xmin + dxrange * (mpx * 2 - 1 + dv / 2))
  tbl[3] = ymin + mma(0, dyrange * (mpy * 2 - 1 - dv / 2))
  tbl[4] = mmi(ymax, ymin + dyrange * (mpy * 2 - 1 + dv / 2))
end

local tbl = {-1000, 1000, -1000, 1000}
local rep = 10000000
while true do
  solve(tbl)
  if 1.84 < os.clock() then break end
end
local xm, ym = (tbl[1] + tbl[2]) / 2, (tbl[3] + tbl[4]) / 2
local ret = func(xm, ym)
print(string.format("%.10f", ret))
