# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import combinations

def run():
    N, K = map(int, sysread().split())
    niku = []
    for _ in range(N):
        niku.append(list(map(int, sysread().split())))

    high_t = (2000**2 + 2000**2) ** (0.5) * 100
    low_t = 1e-6
    current = (high_t + low_t)/2

    while high_t - low_t > 1e-6:
        for i, j in combinations(list(range(N)), 2):
            done = False
            xi, yi, ci = niku[i]
            xj, yj, cj = niku[j]
            ci = current / ci
            cj = current / cj
            xj -= xi
            yj -= yi
            a = (ci ** 2 - cj **2 + xj **2 + yj **2) / 2
            s = (xj ** 2 + yj **2) * ci ** 2 - a ** 2
            if s >= 0:
                s = s ** 0.5
            else:
                continue
            C = xj ** 2 + yj ** 2
            X1 = ((a * xj) + (yj * s)) / C + xi
            X2 = ((a * xj) - (yj * s)) / C + xi
            Y1 = ((a * yj) + (xj * s)) / C + yi
            Y2 = ((a * yj) - (xj * s)) / C + yi
            K1 = 2
            K2 = 2

            for k in range(N):
                if k == i or k == j:
                    continue
                xk, yk, ck = niku[k]
                if (xk - X1) ** 2 + (yk - Y1) ** 2 <= (current / ck) ** 2:
                    K1 += 1
                if (xk - X2) ** 2 + (yk - Y2) ** 2 <= (current / ck) ** 2:
                    K2 += 1
                if K1 >= K or K2 >= K:
                    done = True
                    break
            if done:
                break

        if done:
            high_t = current
            current = (high_t + low_t) / 2
        else:
            low_t = current
            current = (high_t + low_t) / 2

    print(low_t)




if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import combinations

def run():
    N, K = map(int, sysread().split())
    niku = []
    for i in range(N):
        niku.append([i]+list(map(int, sysread().split())))

    high_t = math.sqrt(2000**2 + 2000**2) * 101
    low_t = 0
    current = (high_t + low_t) / 2
    delta = 5e-7
    if K == 1:
        print(0)
        return None

    while high_t - low_t > delta:
        done = False
        c = [(current / ci) ** 2 for _, _, _, ci in niku]
        for i, xi, yi, _ in niku:
            if done:
                break
            K0 = 0
            for k, xk, yk, _ in niku:
                if done:
                    break
                ck = c[k]
                if ((xi - xk) ** 2 + (yi - yk) ** 2) <= ck + delta:
                    K0 += 1
                if K0 >= K:
                    done = True


        for (i, xi, yi, _), (j, xj, yj, _) in combinations(niku, 2):
            if done:
                break
            ci, cj = c[i], c[j]
            xj -= xi
            yj -= yi
            d2 = xj ** 2 + yj ** 2
            d = math.sqrt(d2)

            x = (d2 + ci - cj) / (2 * d)
            e = ci - x ** 2
            if e < 0 or math.sqrt(ci) + math.sqrt(cj) < d:
                continue
            else:
                e = math.sqrt(e)

            vx1, vy1 = xj / d, yj / d
            vx2, vy2 = yj / d, -xj / d

            X1 = vx1 * x + vx2 * e + xi
            X2 = vx1 * x - vx2 * e + xi
            Y1 = vy1 * x + vy2 * e + yi
            Y2 = vy1 * x - vy2 * e + yi

            K1 = 0
            K2 = 0

            for k, xk, yk, _ in niku:
                if done:
                    break
                ck = c[k]
                if ((xk - X1) ** 2 + (yk - Y1) ** 2) <= ck + delta:
                    K1 += 1
                if ((xk - X2) ** 2 + (yk - Y2) ** 2) <= ck + delta:
                    K2 += 1
                if K1 >= K or K2 >= K:
                    done = True


        if done:
            high_t = current
            current = (high_t + low_t) / 2
        else:
            low_t = current
            current = (high_t + low_t) / 2

    print((low_t + high_t) / 2)
    return None

if __name__ == "__main__":
    run()