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 = 128
  local dxrange = (xmax - xmin) / (dv * 2)
  local dyrange = (ymax - ymin) / (dv * 2)
  local xp = {}
  for i = 1, dv do
    xp[i] = xmin + dxrange * (i * 2 - 1)
  end
  local yp = {}
  for i = 1, dv do
    yp[i] = ymin + dyrange * (i * 2 - 1)
  end
  local mp, minval = false, 0
  for i = 1, dv do
    for j = 1, dv do
      local v = func(xp[i], yp[j])
      if not mp or v < minval then
        minval = v
        mp = {i, j}
      end
    end
  end
  tbl[1] = xmin + mma(0, dxrange * (mp[1] * 2 - 1 - dv / 4))
  tbl[2] = mmi(xmax, xmin + dxrange * (mp[1] * 2 - 1 + dv / 4))
  tbl[3] = ymin + mma(0, dyrange * (mp[2] * 2 - 1 - dv / 4))
  tbl[4] = mmi(ymax, ymin + dyrange * (mp[2] * 2 - 1 + dv / 4))
end

local tbl = {-1000, 1000, -1000, 1000}
local rep = 10000000
while true do
  solve(tbl)
  if 1.85 < 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))
