#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef double T;
typedef pair<T,T> P;

// difference
P operator-(const P& lhs, const P& rhs)
{
	return P(lhs.first-rhs.first,lhs.second-rhs.second);
}

P operator+(const P& lhs, const P& rhs)
{
	return P(lhs.first+rhs.first, lhs.second+rhs.second);
}

// scalar product
P operator*(T t, P p){
	return P(t*p.first,t*p.second);
}

P operator/(P p, T t){
	return P(p.first/t,p.second/t);
}

P rot(P p){
	return P(-p.second,p.first);
}

// cross product
T Cross(const P& lhs, const P& rhs)
{
	return lhs.first*rhs.second-lhs.second*rhs.first;
}

// inner product 
T Dot(const P& lhs, const P& rhs)
{
	return lhs.first*rhs.first+lhs.second*rhs.second;
}

// square of distance
T Dist2(const P& lhs, const P& rhs){
	return Dot(lhs-rhs,lhs-rhs);
}

// b is on segment a c
bool onSegment(P a, P b, P c){
	P v=c-a;
	P w=b-a;
	return Cross(v,w)==0 && 0<=Dot(v,w)&&Dot(v,w)<=Dot(v,v);
}


// intersection of segments
bool Intersects(P s0, P e0, P s1, P e1)
{
	P a=s1-s0;
	P v=e0-s0;
	P w=s1-e1;
	T det=Cross(v,w);
	T t0=w.second*a.first-w.first*a.second;
	T t1=-v.second*a.first+v.first*a.second;
	if (det<0){
		if (det <= t0 && det <= t1 && t0 <= 0 && t1 <= 0){
			return true;
		}
	}
	else if (det > 0)
	{
		if (0 <= t0 && 0 <= t1 && t0 <= det && t1 <= det){
			return true;
		}
	}
	return onSegment(s0,s1,e0) ||
		onSegment(s0,e1,e0)||
		onSegment(s1,s0,e1)||
		onSegment(s1,e0,e1);
}

// intersection of line
bool IntersectLineParam(P s0, P e0, P s1, P e1, T& t0, T& t1)
{
	P a=s1-s0;
	P v=e0-s0;
	P w=s1-e1;
	T det=Cross(v,w);
	if(det == 0){
		return false;
	}
	t0=Cross(a,w)/det;
	t1=Cross(v,a)/det;
	return true;
}


P Interpolate(P s, P e, T t)
{
	return (1-t)*s+t*e;
}

bool IntersectLine(P s0, P e0, P s1, P e1, P& result)
{
	T t0,t1;
	if(IntersectLineParam(s0,e0,s1,e1,t0,t1)){
		result=Interpolate(s0,e0,t0);
		return true;
	}
	return false;
}

// intersection of polygons
bool Intersects(vector<P>& lhs, vector<P>& rhs)
{
	for(int i=1;i<lhs.size();i++){
		for (int j=1;j<rhs.size();j++){
			if (Intersects(lhs[i],lhs[i-1],rhs[j],rhs[j-1])){
				return true;
			}
		}
	}
	return false;
}

bool IsInside(vector<P>& ps, P p)
{
	int count=0;
	for(int i=0;i<ps.size();i++){
		P a=ps[i];
		P b=ps[(i+1)%ps.size()];
		if(min(a.first,b.first)<=p.first&&p.first<max(a.first,b.first))
		{
			T c=Cross(p-a,b-a);
			if(c==0){
				return true;
			}
			if(c<0){
				count--;
			}
			else
			{
				count++;
			}
		}
		else if (a.first==p.first&&b.first==p.first)
		{
			if(min(a.second,b.second)<=p.second&&p.second<=max(a.second,b.second))
			{
				return true;
			}
		}
	}
	return count!=0;
}

T area(vector<P> ps){
	T sum=0;
	for(int i=0;i<ps.size();i++){
		sum+=Cross(ps[i],ps[(i+1)%ps.size()]);
	}
	return abs(sum)/2;
}

// convex full
void full(vector<P>& in, vector<P>& out)
{
	sort(in.begin(),in.end());
	for(int i=0;i<in.size();i++){
		while(out.size()>=2){
			P v=out[out.size()-1]-out[out.size()-2];
			P w=in[i]-out[out.size()-1];
			if(Cross(v,w)>=0){
				out.pop_back();
			}
			else
			{
				break;
			}
		}
		out.push_back(in[i]);
	}
	for(int i=in.size()-2,k=max((int)out.size(),1);i>=0;i--){
		while(out.size()>k){
			P v=out[out.size()-1]-out[out.size()-2];
			P w=in[i]-out[out.size()-1];
			if(Cross(v,w)>=0){
				out.pop_back();
			}
			else
			{
				break;
			}
		}
		out.push_back(in[i]);
	}
}

// 円と直線の交点
void IntersectCircleLine(P c, T r, P s, P v, vector<P>& result){
	P w=c-s;
	T v2=Dot(v,v);
	P a=Dot(v,w)*v/v2+s;
	T d2=Dist2(c,a);
	if(d2>r*r){
		return;
	}else if(d2==r*r)
	{
		result.push_back(a);
	}

	P e=v/sqrt(v2);
	T len=sqrt(r*r-d2);
	result.push_back(len*e+a);
	result.push_back((-len)*e+a);
}

// 円と円の交点
void IntersectCircleCircle(P c0, T a, P c1, T b, vector<P>& result){
	T d2=Dist2(c0,c1);
	if(d2>(a+b)*(a+b)){
		return;
	}

	P s=Interpolate(c0,c1,((a*a-b*b)/d2+1)/2);
	P d=c0-c1;
	IntersectCircleLine(c0,a,s,P(d.second,-d.first),result);
}

// 距離の比率が a:b の円を求める
void RatioConstantCircle(P c0, T a, P c1, T b, P& c, T& r){
	if(a>b){
		swap(c0,c1);
		swap(a,b);
	}
	P p=Interpolate(c0,c1,a/(a+b));
	P q=Interpolate(c0,c1,-a/(b-a));
	c=(p+q)/2;
	r=sqrt(Dist2(c,p));
}

// 三円が交差するか？
bool Intersect3Circles(P c0, T r0, P c1, T r1, P c2, T r2){
	vector<P> result;
	for(int i=0;i<3;i++){
		result.clear();
		IntersectCircleCircle(c0,r0,c1,r1,result);
		for(auto p:result){
			if(Dist2(p,c2)<=r2*r2){
				return true;
			}
		}
		if(Dist2(c0,c1)<=r1*r1&&Dist2(c0,c2)<=r2*r2){
			return true;
		}
		swap(c0,c1);
		swap(c1,c2);
		swap(r0,r1);
		swap(r1,r2);
	}
	return false;
}

std::vector<P> ps;
std::vector<double> c;
long long N;
long long K;

double f(P p){
	vector<double> t;
	for(int i=0;i<N;i++){
		t.push_back(c[i]*c[i]*Dist2(ps[i],p));
	}
	nth_element(t.begin(),t.begin()+K-1,t.end());
	return sqrt(t[K-1]);
}

void solve(){
	double ret=DBL_MAX;
	for(int i=0;i<N;i++){
		ret=min(ret,f(ps[i]));
		for(int j=i+1;j<N;j++){
			P c0=(c[i]*ps[i]+c[j]*ps[j])/(c[i]+c[j]);
			ret=min(ret,f(c0));
			P cij;
			double rij=0;
			P vij=P(0,0);
			if(c[i]!=c[j]){
				RatioConstantCircle(ps[i],c[j],ps[j],c[i],cij,rij);
			}
			else{
				cij=(ps[i]+ps[j])/2;
				vij=rot(ps[i]-ps[j]);
			}
			for(int k=j+1;k<N;k++){
				P cik;
				double rik=0;
				P vik=P(0,0);
				vector<P> rs;
				if(c[i]!=c[k]){
					RatioConstantCircle(ps[i],c[k],ps[k],c[i],cik,rik);
					if(c[i]!=c[j]){
						IntersectCircleCircle(cij,rij,cik,rik,rs);
					}
					else{
						IntersectCircleLine(cik,rik,cij,vij,rs);
					}
				}
				else{
					cik=(ps[i]+ps[k])/2;
					vik=rot(ps[i]-ps[k]);
					if(c[i]!=c[j]){
						IntersectCircleLine(cij,rij,cik,vik,rs);
					}
					else{
						P r;
						if(IntersectLine(cij,cij+vij,cik,cik+vik,r)){
							rs.push_back(r);
						}
					}
				}
				for(auto c1:rs){
					ret=min(ret,f(c1));
				}
			}
		}
	}
	cout.precision(17);
	cout << ret << endl;
}

int main(){
    scanf("%lld",&N);
    scanf("%lld",&K);

	ps.resize(N);
	c.resize(N);
    for(int i = 0 ; i < N ; i++){
		double x,y;
        scanf("%lf",&x);
        scanf("%lf",&y);
        scanf("%lf",&c[i]);
		ps[i]=P(x,y);
    }
    solve();
    return 0;
}


Measured memory_bytes: 256