#include<stdio.h>
#include<math.h>
#define EPS 1e-10
typedef struct{
    double x; double y;
}Point;
int n;
int h[50];
Point s,e,ll[50],ul[50],ur[50],lr[50];

int change(int x){
    if(x>0) return 1;
    else if(x<0) return -1;
    else return 0;
}
int intersect(Point a,Point b,Point c,Point d){//交差
    int ta=(c.x-d.x)*(a.y-c.y)+(c.y-d.y)*(c.x-a.x);
    int tb=(c.x-d.x)*(b.y-c.y)+(c.y-d.y)*(c.x-b.x);
    int tc=(a.x-b.x)*(c.y-a.y)+(a.y-b.y)*(a.x-c.x);
    int td=(a.x-b.x)*(d.y-a.y)+(a.y-b.y)*(a.x-d.x);
    //オーバーフロー
    ta=change(ta); tb=change(tb); tc=change(tc); td=change(td);
    return ta*tb<0 && tc*td<0;
    
}
double PtoQ(Point p1, Point p2) {
    return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));
}
//ベクトル外積
double cross_vector(Point vl, Point vr) {
    return vl.x * vr.y - vl.y * vr.x;
}

//点Pと線(AB)の距離
double PtoAB(Point P,Point A,Point B ){
    double a=B.x-A.x;
    double b=B.y-A.y;
    double a2=a*a;
    double b2=b*b;
    double r2=a2+b2;
    double tt=-(a*(A.x-P.x)+b*(A.y-P.y));
    if(tt<0){
        return sqrt((A.x-P.x)*(A.x-P.x)+(A.y-P.y)*(A.y-P.y));
    }
    if( tt > r2 ) {
        return sqrt((B.x-P.x)*(B.x-P.x) + (B.y-P.y)*(B.y-P.y));
    }
    double f1 = a*(A.y-P.y)-b*(A.x-P.x);
    return sqrt((f1*f1)/r2);
}
double linetoline(double min,Point a,Point b){//2線分の距離
    double tmp;
    if(min>(tmp=PtoAB(a,s,e))) min=tmp;
    if(min>(tmp=PtoAB(b,s,e))) min=tmp;
    if(min>(tmp=PtoAB(s,a,b))) min=tmp;
    if(min>(tmp=PtoAB(e,a,b))) min=tmp;
    return min;
}
double distance(int i){//ブロック-直線間
    double tmp,min=1e10;
    if(min>(tmp=linetoline(min,ll[i],ul[i]))) min=tmp;
    if(min>(tmp=linetoline(min,ul[i],ur[i]))) min=tmp;
    if(min>(tmp=linetoline(min,ur[i],lr[i]))) min=tmp;
    if(min>(tmp=linetoline(min,lr[i],ll[i]))) min=tmp;
    //printf("min:%f\n",min);
    return min;
}
double cal(double x,double h){
    return (x*x+h*h)/(2.0*h);
}
int main(void){
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        scanf("%lf%lf%lf%lf",&s.x,&s.y,&e.x,&e.y);
        /*if(s.x>e.x){
         Point tmp=s; s=e; e=tmp;
         }*/
        double a,b,c,d;
        for(int i=0;i<n;i++){
            scanf("%lf%lf%lf%lf%d",&a,&b,&c,&d,&h[i]);
            ll[i].x=a; ll[i].y=b; ul[i].x=a; ul[i].y=d;
            ur[i].x=c; ur[i].y=d; lr[i].x=c; lr[i].y=b;
        }
        int flag=0;
        for(int i=0;i<n;i++){//交差判定
            if(intersect(s,e,ll[i],ul[i])||intersect(s,e,ul[i],ur[i])||
               intersect(s,e,ur[i],lr[i])||intersect(s,e,lr[i],ll[i])){
                flag=1; break;
            }
            else if((ll[i].x<s.x&&s.x<ur[i].x&&
                    ll[i].y<s.y&&s.y<ur[i].y)||
                    (ll[i].x<e.x&&e.x<ur[i].x&&
                    ll[i].y<e.y&&e.y<ur[i].y)){//内側
                flag=2; break;
            }
        }
        if(flag) printf("0.0000\n");
        else{
            double min=1e10,tmp;
            for(int i=0;i<n;i++){
                tmp=distance(i);
                if(tmp<h[i]){
                    if(min>tmp) min=tmp;
                }
                else{
                    if(min>cal(tmp,h[i])) min=cal(tmp,h[i]);
                }
            }
            printf("%.4f\n",min);
        }
    }
}



Measured memory_bytes: 2068