#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

const double Pi = 3.1415926535897932384626433832795;

const long MaxN = 1001;

string fajl_in = "sanke.in";
string fajl_out = "sanke.out";


struct Event{
	double time;
	bool usao;
	
	Event(double t, bool in):time(t), usao(in){}
	
	friend bool operator<(const Event &a, const Event &b){
		if (fabs(a.time - b.time) < 1e-9) return a.usao && !b.usao;
		else return a.time < b.time;
	}
};


double cx, cy;

int n;
double mx[MaxN], my[MaxN];
double px[MaxN], py[MaxN];
double speed[MaxN];

int K;


double dist(double x1, double y1, double x2, double y2){
	return sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

bool intersection(double px, double py, double qx, double qy, double r, double &x1, double &y1, double &x2, double &y2){
	double A = qy - py, B = px - qx, C =  px * qy - py * qx;
	double A1 = -B, B1 = A, C1 = A1 * cx + B1 * cy;
	
	double d = A * B1 - A1 * B;
	double dx = C * B1 - C1 * B;
	double dy = A * C1 - A1 * C;
	
	double xpr = dx / d, ypr = dy / d;
	
	double udaljenost = dist(xpr, ypr, cx, cy);
	if (udaljenost > r + 1e-9) return false;
	else{
		double alfa = acos(udaljenost / r);
		
		double tng = atan2(ypr - cy, xpr - cx);
		if (tng < 0) tng += 2 * Pi;
		
		double u1 = tng - alfa;
		if (u1 < 0) u1 += 2 * Pi;
		
		double u2 = tng + alfa;
		if (u2 >= 2 * Pi) u2 -= 2 * Pi;
		
		x1 = cx + r * cos(u1); y1 = cy + r * sin(u1);
		x2 = cx + r * cos(u2); y2 = cy + r * sin(u2);
			
		return true;
	}
}


bool solve(double r){
	vector<Event> dogadjaj;
	for (int i = 0; i < n; i++){
		double x1, y1, x2, y2;
		
		if (intersection(mx[i], my[i], px[i], py[i], r, x1, y1, x2, y2)){	
			if (dist(mx[i], my[i], cx, cy) < r + 1e-9){ 	// da li je djak vec unutra
				dogadjaj.push_back(Event(0.0, true));
				if (px[i] != mx[i]){
					if ((x1 - mx[i]) / (px[i] - mx[i]) > 0)	dogadjaj.push_back(Event(dist(x1, y1, mx[i], my[i]) / speed[i], false));
					else  dogadjaj.push_back(Event(dist(x2, y2, mx[i], my[i]) / speed[i], false));
				}
				else{
					if ((y1 - my[i]) / (py[i] - my[i]) > 0)	dogadjaj.push_back(Event(dist(x1, y1, mx[i], my[i]) / speed[i], false));
					else  dogadjaj.push_back(Event(dist(x2, y2, mx[i], my[i]) / speed[i], false));
				}
			}
			else if ((px[i] != mx[i] && (x1 - mx[i]) / (px[i] - mx[i]) > 0) || (py[i] != my[i] && (y1 - my[i]) / (py[i] - my[i]) > 0)){
				double t1 = dist(x1, y1, mx[i], my[i]) / speed[i];
				double t2 = dist(x2, y2, mx[i], my[i]) / speed[i];
				if (t1 > t2) swap(t1, t2);
				dogadjaj.push_back(Event(t1, true));
				dogadjaj.push_back(Event(t2, false));
			}
		
		}
	}
	
	sort(dogadjaj.begin(), dogadjaj.end());
	
	int unutra = 0;
	for (int i = 0; i < dogadjaj.size(); i++){
		if (dogadjaj[i].usao) unutra++;
		else unutra--;
		
		if (unutra == K) return true;
	}
	
	return false;
}


void init(){
	FILE *f;
	f = fopen(fajl_in.c_str(), "r");
	fscanf(f, "%lf %lf", &cx, &cy);
	fscanf(f, "%d %d", &n, &K);
	for (int i = 0; i < n; i++){
		fscanf(f, "%lf %lf %lf %lf", &mx[i], &my[i], &px[i], &py[i]);
		speed[i] = dist(mx[i], my[i], px[i], py[i]);
	}
	fclose(f);
}

int main(){
	init();
	
	double l = 0.00001, r = 15000.0;
	for (int korak = 0; korak < 100; korak++){
		double m = (l + r) / 2.0;
		if (solve(m)) r = m;
		else l = m;
	}
	
	FILE *f;
	f = fopen(fajl_out.c_str(), "w");
	fprintf(f, "%.5lf\n", l);
	fclose(f);
	
//	int asd; cin >> asd;
	return 0;
}
