#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <complex>
#include <queue>
#include <sstream>

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;
typedef vector<P> Poly;

#define x real()
#define y imag()

const double EPS = 1e-9;
const double PI = acos(-1);


inline bool near(const P& p,const P& q){ return abs(p-q)<EPS;}

double dot(const P& p,const P& q){ return p.x*q.x+p.y*q.y;}
double det(const P& p,const P& q){ return p.x*q.y-p.y*q.x;}

enum LPposit{
  P_CD = -2, //counter direction
  P_CW = -1, //clock wise
  P_OS = 0, //on segment
  P_CCW = 1, //counter clock wise
  P_D = 2 //direction
};

inline double ccw_b(const P& p,const P& q,const P& r){  return det(q-p,r-p);}

LPposit ccw(const P& p, const P& q, const P& r){
  double c = ccw_b(p,q,r);
  if(c<-EPS) return P_CW;
  if(c>EPS) return P_CCW;
  if(dot(q-p,r-p)<-EPS) return P_CD;
  if(dot(p-q,r-q)<-EPS) return P_D;
  return P_OS;
}

inline double Sabs(const L& l){ return abs(l.first-l.second);}
inline double LPdist(const L& l,const P& p){ return abs(ccw_b(l.first,l.second,p))/Sabs(l);}

inline double SPdist(L l,P p){
  double a = abs(l.first-p);
  double b = abs(l.second-p);
  double c = Sabs(l);
  if(b*b+c*c>a*a && a*a+c*c>b*b) return LPdist(l,p);
  return min(a,b);
}

bool crossS(const L& p,const L& q){
  return
    ccw(p.first,p.second,q.first)*ccw(p.first,p.second,q.second)<=0 &&
    ccw(q.first,q.second,p.first)*ccw(q.first,q.second,p.second)<=0;
}

double SSdist(const L& a,const L& b){
  if(crossS(a,b)) return 0;
  double tmp = min(SPdist(a,b.first),SPdist(a,b.second));
  return min(tmp, min(SPdist(b,a.first), SPdist(b,a.second)));
}

P intersect(const L& p,const L& q){
  P vp = p.second-p.first;
  P vq = q.second-q.first;
  P c(det(vp,p.first), det(vq,q.first));
  return P(det(c, P(vp.x, vq.x)), det(c, P(vp.y, vq.y))) / det(vp, vq);
}

double area(const Poly& p){
  double ret = 0;
  int n = p.size();
  for(int i=0;i<n;++i) ret+=det(p[i],p[(i+1)%n]);
  return abs(ret)/2;
}

/* ?????¨??´???????????? */
vector<P> CLintersect(const L& l,const C& c){
  vector<P> ret;
  double di = LPdist(l,c.first);
  double r = c.second;
  if(di+EPS > r) return ret;
  P v = l.second-l.first;
  v/=abs(v);
  P rv = v*P(0,1);
  rv*=di;
  if(LPdist(l,c.first+rv) > di+EPS) rv=-rv;
  v*=sqrt(r*r-di*di);
  ret.push_back(c.first+rv-v);
  ret.push_back(c.first+rv+v);
  return ret;
}

//circle, segment
vector<P> CSintersect(const L& l,const C& c){
  vector<P> u = CLintersect(l,c);
  vector<P> ret;
  for(int i=0;i<u.size();++i){
    if(l.first.x <= u[i].x && u[i].x<=l.second.x &&
       l.first.y <= u[i].y && u[i].y<=l.second.y)
      ret.push_back(u[i]);
  }
  return ret;
}

vector<P> CCintersect(C c,C d){
  vector<P> ret;
  const double dist = abs(c.first-d.first);
  const double cr = c.second;
  const double dr = d.second;

  if(dist > cr+dr) return ret;
  if(dist < abs(cr-dr)) return ret;

  const double s = (cr+dr+dist)/2;
  const double area = sqrt(s*(s-cr)*(s-dr)*(s-dist));
  const double h = 2*area/dist;

  P v = d.first - c.first; v/=abs(v);
  const P m = c.first+sqrt(cr*cr-h*h)*v;
  const P n = v*P(0,1);

  ret.push_back(m+n*h);
  ret.push_back(m-n*h);
  return ret;
}

/* ?????? */
namespace std{
  bool operator < (const P& a,const P& b){
    return a.x!=b.x?a.x<b.x : a.y<b.y;
  }
}
Poly convexHull(vector<P> ps){
  int n = ps.size();
  sort(ps.begin(),ps.end());
  Poly ret(2*n);
  int m=0;
  for(int i=0;i<n;++i){
    while(m>=2 && ccw(ret[m-2],ret[m-1],ps[i])<0) --m;
    ret[m++] = ps[i];
  }
  int t = m;
  for(int i=n-2;i>=0;--i){
    while(m>=t && ccw(ret[m-2], ret[m-1], ps[i])<0) --m;
    ret[m++] = ps[i];
  }

  ret.resize(m-1);
  return ret;
}

/* ???????§???¢????????¨?????? O(log n)*/
/* ?????????????????¨??????1  ?¢?????????????2  ?????¨??????0?????????*/
int inConvex(const Poly& ps, P p){
  int n = ps.size();
  P g = (ps[0]+ps[n/3]+ps[n*2/3])/3.0;
  if(g==p) return 1;
  P gp = p-g;
  int l = 0, r = n;
  while(l+1<r){
    int mid = (l+r)/2;
    P gl = ps[l]-g;
    P gm = ps[mid]-g;
    if(det(gl,gm)>0){
      if(det(gl,gp)>=0 && det(gm,gp)<=0) r=mid;
      else l = mid;
    }
    else{
      if(det(gl,gp)<=0 && det(gm,gp)>=0) l=mid;
      else r = mid;
    }
  }
  r%=n;
  double cr = det(ps[l]-p,ps[r]-p);
  if(cr==0) return 2;
  if(cr<0) return 0;
  return 1;
}

double dst(L crs,double s,double t,double u,double v){
  vector<P> pos;
  pos.push_back(P(s,t));
  pos.push_back(P(s,v));
  pos.push_back(P(u,t));
  pos.push_back(P(u,v));
  double ret = 1000;
  for(int i=0;i<4;++i)
    ret = min(ret,SSdist(crs,L(pos[i],pos[(i+1)%4])));
  return ret;
}

int main(){
  int n;
  while(cin>>n,n){
    double sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    L crs = L(P(sx,sy),P(ex,ey));
    double R = 1000;
    for(int i=0;i<n;++i){
      double s,t,u,v,h;
      cin >> s >> t >> u >> v >> h;
      double d = dst(crs,s,t,u,v);
      double r = (h>=d)?d:((d*d+h*h)/2/h);
      R = min(R,r);
    }
    cout << R << endl;
  }
  return 0;
}

Measured memory_bytes: 1316