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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)
typedef complex<double> P;
typedef vector<P> G;
double const inf=1e10;
double const eps=1e-8;
double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}

double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}

P projection(const L &l, const P &p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}

bool intersectSS(const L &s, const L &t) {
    return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
        ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < eps; // triangle inequality
}

bool intersectRS(const G &r, const L &l){
    if(r[0].real()<=l[0].real() && l[0].real()<=r[2].real() &&
       r[0].imag()<=l[0].imag() && l[0].imag()<=r[2].imag() &&
       r[0].real()<=l[1].real() && l[1].real()<=r[2].real() &&
       r[0].imag()<=l[1].imag() && l[1].imag()<=r[2].imag()){
        return true;
    }
    rep(i,4){
        L m(r[i],r[(i+1)%4]);
        if(intersectSS(l,m)) return true;
    }
    return false;
}

double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

int n;
P s,e;
vector<G> rs;
vd hs;
vvd d;

double maxr(P p, G const& rect, double h){
    double res=inf;
    rep(i,4){
        double d=distanceSP({rect[i],rect[(i+1)%4]},p);
        if(d<h){
            res=min(res,d);
        }else{
            res=min(res,(d*d+h*h)/(2*h));
        }
    }
    // printf(" %lf\n",res);
    return res;
}

double solve(){
    double ans=inf;
    L l(s,e);
    rep(i,n){
        if(intersectRS(rs[i],l)) return 0;
        rep(j,4){
            P prj = projection(l,rs[i][j]);
            if(!intersectSP(l,prj)) continue;
            ans=min(ans, maxr(prj,rs[i],hs[i]));
        }
        // printf(" %lf\n",ans);
        ans=min(ans,maxr(s,rs[i],hs[i]));
        ans=min(ans,maxr(e,rs[i],hs[i]));
    }
    return ans;
}

int main(){
    while(cin>>n && n){
        double sx,sy,ex,ey;
        cin >> sx>>sy>>ex>>ey;
        s = P(sx,sy);
        e = P(ex,ey);
        rs.resize(n);
        hs.resize(n);
        rep(i,n){
            double mx,my,Mx,My;
            cin>>mx>>my>>Mx>>My >> hs[i];
            rs[i] = {P(mx,my),P(Mx,my),P(Mx,My),P(mx,My)};
        }
        printf("%.5lf\n",solve());
    }
}

Measured memory_bytes: 1284