#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

#include <complex>
typedef complex<double> P;

// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
 return (a.real() * b.imag() - a.imag() * b.real());
}
// 内積 (dot product) : a・b = |a||b|cosΘ
double dot(P a, P b) {
 return (a.real() * b.real() + a.imag() * b.imag());
}
// 点a,bを通る直線と点cとの距離
double distance_l_p(P a, P b, P c) {
 return abs(cross(b-a, c-a)) / abs(b-a);
}
// 点a,bを端点とする線分と点cとの距離
double distance_ls_p(P a, P b, P c) {
 if ( dot(b-a, c-a) < EPS ) return abs(c-a);
 if ( dot(a-b, c-b) < EPS ) return abs(c-b);
 return abs(cross(b-a, c-a)) / abs(b-a);
}
// 点cが線分a,b上にあるかないか(2)
int is_point_on_line(P a, P b, P c) {
 // |a-c| + |c-b| <= |a-b| なら線分上
 return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}
// a1,a2を端点とする線分とb1,b2を端点とする線分の交差判定
int is_intersected_ls(P a1, P a2, P b1, P b2) {
 if (( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < -EPS ) &&
     ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < -EPS ))
    return true;
 return is_point_on_line(a1, a2, b1) || is_point_on_line(a1, a2, b2) ||
        is_point_on_line(b1, b2, a1) || is_point_on_line(b1, b2, a2);
}

struct block{
	int minx,miny,maxx,maxy,h;
	P p(int n){
		switch(n){
		case 0:
			return P(minx,miny);
		case 1:
			return P(minx,maxy);
		case 2:
			return P(maxx,maxy);
		case 3:
			return P(maxx,miny);
		}
	}
};
int main(){
	cout.precision(16);
	int n;
	while(cin>>n,n){
		int sx,sy,ex,ey;
		cin>>sx>>sy>>ex>>ey;
		vector<block> blocks(n);
		REP(i,n){
			cin>>blocks[i].minx>>blocks[i].miny>>blocks[i].maxx>>blocks[i].maxy>>blocks[i].h;
		}
		double ans=INT_MAX;
		bool itsc=false;
		REP(i,n){
			REP(j,4){
				if(is_intersected_ls(P(sx,sy),P(ex,ey),blocks[i].p(j),blocks[i].p((j+1)%4))){
					itsc=true;
					break;
				}
				if(sx+EPS>blocks[i].minx&&sx-EPS<blocks[i].maxx&&sy+EPS>blocks[i].miny&&sy-EPS<blocks[i].maxy){
					itsc=true;
					break;
				}
				if(ex+EPS>blocks[i].minx&&ex-EPS<blocks[i].maxx&&ey+EPS>blocks[i].miny&&ey-EPS<blocks[i].maxy){
					itsc=true;
					break;
				}
			}
			if(itsc){
				break;
			}
		}
		if(itsc){
			cout<<0<<endl;
		}else{
			REP(i,n){
				double r=INT_MAX;
				REP(j,4){
					double d=distance_ls_p(P(sx,sy),P(ex,ey),blocks[i].p(j));
					r=min(r,(blocks[i].h*blocks[i].h+d*d)/2/blocks[i].h);
					double ds=distance_ls_p(blocks[i].p(j),blocks[i].p((j+1)%4),P(sx,sy));
					r=min(r,(blocks[i].h*blocks[i].h+ds*ds)/2/blocks[i].h);
					double de=distance_ls_p(blocks[i].p(j),blocks[i].p((j+1)%4),P(ex,ey));
					r=min(r,(blocks[i].h*blocks[i].h+de*de)/2/blocks[i].h);
				}
				if(blocks[i].h>=r){
					REP(j,4){
						double d=distance_ls_p(P(sx,sy),P(ex,ey),blocks[i].p(j));
						r=min(r,d);
						double ds=distance_ls_p(blocks[i].p(j),blocks[i].p((j+1)%4),P(sx,sy));
						r=min(r,ds);
						double de=distance_ls_p(blocks[i].p(j),blocks[i].p((j+1)%4),P(ex,ey));
						r=min(r,de);
					}
				}
				ans=min(ans,r);
			}
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 1300