#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

//// definition of point
#define x(p) real(p)
#define y(p) imag(p)

const double eps=1e-10;
const double inf=1e12;
const double PI=acos(-1);
typedef complex<double> P;

namespace std{
  bool operator<(const P& a,const P& b){
    return x(a)==x(b)?y(a)<y(b):x(a)<x(b);
  }
}
double cross(const P& a,const P& b){
  return y(conj(a)*b);
}
double dot(const P& a,const P& b){
  return x(conj(a)*b);
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

//// counter-clockwise
int ccw(P a,P b,P c) {
  b=b-a;c=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;
}

//// intersect
bool intersectLL(const L& l,const L& m){
  return abs(cross(l[1]-l[0],m[1]-m[0]))>eps||abs(cross(l[1]-l[0],m[0]-l[0]))<eps;
}
bool intersectLS(const L& l,const L& s){
  return cross(l[1]-l[0],s[0]-l[0])*cross(l[1]-l[0],s[1]-l[0])<eps;
}
bool intersectLP(const L& l,const P& p){
  return abs(cross(l[1]-p,l[0]-p))<eps;
}
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;
}

//// move point
P projection(const L& l,const P& p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*x(c/b);
}
P reflection(const L& l,const P& p) {
  return p+2.0*(projection(l,p)-p);
}
P rotation(const P& a,double r){
  return P(x(a)*cos(r)-y(a)*sin(r),x(a)*sin(r)+y(a)*cos(r));
}

//// distance
double distanceLP(const L& l,const P& p) {
  return abs(p-projection(l,p));
}
double distanceLL(const L& l,const L& m) {
  return intersectLL(l,m)?0:distanceLP(l,m[0]);
}
double distanceLS(const L& l,const L& s) {
  return intersectLS(l,s)?0:min(distanceLP(l,s[0]),distanceLP(l,s[1]));
}
double distanceSP(const L& s,const P& p) {
  const P r=projection(s,p);
  return intersectSP(s,r)?abs(r-p):min(abs(s[0]-p),abs(s[1]-p));
}
double distanceSS(const L& s,const L& t) {
  return intersectSS(s,t)?0:min(min(distanceSP(s,t[0]),distanceSP(s,t[1])),
                                min(distanceSP(t,s[0]),distanceSP(t,s[1])));
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    L route(P(x1,y1),P(x2,y2));
    double res=inf;
    bool ok=true;
    rep(i,n){
      double h;
      cin>>x1>>y1>>x2>>y2>>h;
      P p1(x1,y1),p2(x1,y2),p3(x2,y2),p4(x2,y1);
      double dist=inf;
      if(intersectSS(route,L(p1,p2))||intersectSS(route,L(p2,p3))||intersectSS(route,L(p3,p4))||intersectSS(route,L(p4,p1))
        ||(x1<=x(route[0])&&x(route[0])<=x2&&y1<=y(route[0])&&y(route[0])<=y2))ok=false;
      minch(dist,distanceSS(route,L(p1,p2)));
      minch(dist,distanceSS(route,L(p2,p3)));
      minch(dist,distanceSS(route,L(p3,p4)));
      minch(dist,distanceSS(route,L(p4,p1)));
      double ns;
      if(h>dist+eps){
        ns=dist;
      }else{
        ns=(h*h+dist*dist)/(2.0*h);
      }
      minch(res,ns);
    }
    if(!ok) printf("%.10f\n",0.0);
    else printf("%.10f\n", res);
  }
	return 0;
}

Measured memory_bytes: 3112