0 0 10 10
1
10 0 0 1.57079
0
 -88 -68 -10 -61
5
-64 -55 3.09648 0.28346
-8 -52 2.46781 0.13262
-8 -59 3.02445 0.00119
-40 90 2.37292 0.15686
-29 -34 2.73957 0.18287
0
 0 0 10 10
2
10 0 0 1.57079
10 5 0 0.7854
1
 -100000 -100000 100000 100000
1
100000 0 0 15.70796
0
 -3 -7 -14 2
5
-16 19 2.12587 0.30781
9 -19 3.27418 0.06595
-1 12 0.12414 8.82294
20 10 6.25657 0.77605
-10 17 0.29502 6.31019
5

14.142079
 7.216642
 7.071084
 2828426.5363
 0.0000

#include <stdio.h>
#include <tchar.h>
#include<cmath>
#include<valarray>
#include<algorithm>
#include<functional>
#include<list>
#include<vector>
#include<map>
#include<iostream>

using namespace std;

typedef pair<double,double> Para;

int N;
int K;
Para A;
Para B;
const double pi=3.141592653589;
double H,L, W,T0,Fi;


valarray<double> tanks;

double rad(Para p1, Para p2);
double cosinus(Para,Para,Para);
Para ortohonal(Para p);

void Init();
double FindVelocity(double t1,double t2);
double TestVelocity(Para p1,Para p2,Para x);
double MakeSolution();



int _tmain(int argc, _TCHAR* argv[])
{
   // ::freopen("stdin.txt","r",stdin);
    
    Init();
    double V=MakeSolution();
    printf("%.4lf\n",V);
    return 0;
}

void Init()
{
    double v1,v2,v3,x,y,alfa;
    cin>>x>>y; A=make_pair(x,y);
    cin>>x>>y; B=make_pair(x,y);
    cin>>N;
    tanks.resize(N);
    double D=hypot(B.first-A.first, B.second-A.second);
    Para p;
    for(int i=0;i<N;i++)
    {
        cin>>p.first>>p.second;
        cin>>alfa>>W;
        double a1=abs(alfa-rad(p,A));
        double a2=abs(alfa-rad(p,B));
        a1=min(a1,2*pi-a1);
        a2=min(a2,2*pi-a2);
        v1=(D*W)/a2;
        Para M=ortohonal(p);
        H=hypot(M.first-p.first,M.second-p.second);
        L=hypot(M.first-A.first,M.second-A.second);
        T0=a1/W;
        Fi=acos(cosinus(M,p,A));
        double t2=T0+Fi/W; 
        //double v22=FindVelocity(T0,t2);
        v2=TestVelocity(A,M,p);
        v3=D/(T0+(acos(cosinus(A,p,B)))/W);
        tanks[i]=max(v1,max(v2,v3));
    }
    sort(&tanks[0],&tanks[N],std::greater<double>());
    cin>>K;
}

double MakeSolution()
{
    if(K==N) return 0;
    for(int i=K;i>0;i--)
    {
        if(tanks[i]!=tanks[i-1]) return tanks[i];
    }
    return tanks[0];
}

double rad(Para p1, Para p2)
{
    double x=p2.first-p1.first;
    double y=p2.second-p1.second;
    double t=y/x;
    double q=(t>0)?atan(t):pi-atan(abs(t));
    if(y<0) return pi+q;
    if(y==0)return (x>0)?0:pi;
    return q;
}

double cosinus(Para p1,Para p0,Para p2)
{
    double d1=sqrt(pow(p1.first-p0.first,2)+pow(p1.second-p0.second,2));
    double d2=sqrt(pow(p2.first-p0.first,2)+pow(p2.second-p0.second,2));
    double t=((p1.first-p0.first)*(p2.first-p0.first)+(p1.second-p0.second)*(p2.second-p0.second))/(d1*d2);
    return t;
}

Para ortohonal(Para p)
{
    double k=(B.second-A.second)/(B.first-A.first);
    if(k==0) return Para(p.first,A.second);
    Para Z((p.first+A.first)/2+(p.second-A.second)/2*k,0);
    Z.second=k*Z.first+A.second-k*A.first;
    return Z;
}

double FindVelocity(double t1,double t2)
{
    double x=L-H*tan(Fi-W*(t1-T0));
    double V1=(L-H*tan(Fi-W*(t1-T0)))/t1;
    double V2=(L-H*tan(Fi-W*(t2-T0)))/t2;
    if(abs(V2-V1)<0.0001) return V1;
    double t0=(t2+t1)/2;
    double delt=t0-0.5*(L*(1+cos(2*(Fi-W*(t0-T0))))/(H*W)-sin(2*(Fi-W*(t0-T0)))/W);
    if(delt<0) return FindVelocity(t1,t0);
    if(delt>0) return FindVelocity(t0,t2);
    if(delt==0) return (H*W)/pow(cos(Fi-W*(t0-T0)),2);
}

double TestVelocity(Para p1,Para p2,Para r)
{
    double tmp=0;
    for(int i=0;i<=1000;i++)
    {
        double x=p1.first+(p2.first-p1.first)*i/1000.;
        double y=p1.second+(p2.second-p1.second)*i/1000.;
        double phi=std::acos(cosinus(p1,r,make_pair(x,y)));
        double time=T0+(phi/W);
        tmp=max(tmp,hypot(x-p1.first,y-p1.second)/time);    
    }
    return tmp;
}