//19
#include<iostream>
#include<complex>
#include<algorithm>

using namespace std;

typedef complex<double> P;

double cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

double dot(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

bool is(P a,P b,P c,P d){
  return (a.real()<=d.real())==(c.real()<=b.real())
    &&(a.imag()<=d.imag())==(c.imag()<=b.imag())
    &&cr(a-b,c-b)*cr(a-b,d-b)<=0&&cr(c-d,a-d)*cr(c-d,b-d)<=0;
}

double dt(P a,P b,P c,P d){
  P p[4]={a,b,c,d};
  double m=1<<30;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      m=min(m,abs(p[i]-p[j+2]));
    }
  }
  for(int i=0;i<2;i++){
    swap(p[0],p[2]);
    swap(p[1],p[3]);
    for(int j=0;j<2;j++){
      if(dot(p[2+j]-p[0],p[1]-p[0])*dot(p[2+j]-p[1],p[0]-p[1])>0){
	m=min(m,fabs(cr(p[2+j]-p[0],p[1]-p[0]))/abs(p[1]-p[0]));
      }
    }
  }
  //  cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<m<<endl;
  return m;
}

int main(){
  for(int n;cin>>n,n;){
    int sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    P s=P(sx,sy),e=P(ex,ey);
    int ix[50],iy[50],ax[50],ay[50],h[50];
    P ll[50],hl[50],hh[50],lh[50];
    bool on=false;
    for(int i=0;i<n;i++){
      cin>>ix[i]>>iy[i]>>ax[i]>>ay[i]>>h[i];
      ll[i]=P(ix[i],iy[i]);
      hl[i]=P(ax[i],iy[i]);
      hh[i]=P(ax[i],ay[i]);
      lh[i]=P(ix[i],ay[i]);
      on|=is(s,e,ll[i],hl[i])|is(s,e,hl[i],hh[i])|is(s,e,hh[i],lh[i])|is(s,e,lh[i],ll[i]);
      on|=ix[i]<=min(sx,ex)&&max(sx,ex)<=ax[i]&&iy[i]<=min(sy,ey)&&max(sy,sy)<=ay[i];
    }
    if(on){
      cout<<0<<endl;
    }else{
      double m=1<<30;
      for(int i=0;i<n;i++){
	P *p[4]={ll+i,hl+i,hh+i,lh+i};
	for(int j=0;j<4;j++){
	  double d=dt(*p[j],*p[(j+1)%4],e,s);
	  if(d<h[i]){
	    m=min(m,d);
	  }else{
	    m=min(m,(d*d+h[i]*h[i])/2/h[i]);
	  }
	}
      }
      cout<<fixed<<m<<endl;
    }
  }
  return 0;
}