#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

#include <complex>
typedef complex<double> Point;
const double EPS = 1e-8;

// テ・ツ?・テ・ツ環崚」ツつケテ」ツδ暗」ツδェテ」ツδシテ」ツδ?」ツ?凝」ツつ嘉・ツョツ淌ヲツ閉ーテ、ツコツ古」ツ?、テ」ツつ津」ツ?ィテ」ツ?」テ」ツ?ヲ Point テ」ツ?ク
istream& operator >> ( istream &s, Point &a )
{
	double r, i;
	s >> r >> i;
	a = Point( r, i );
	return s;
}

// テ・ツ??ァツゥツ催ッツシツ暗」ツδ嘉」ツδε」ツδ暗ァツゥツ催ッツシツ?
double dot( const Point &a, const Point &b )
{
	return a.real() * b.real() + a.imag() * b.imag();
}

// テ・ツ、ツ姪ァツゥツ催ッツシツ暗」ツつッテ」ツδュテ」ツつケテァツゥツ催ッツシツ?
double cross( const Point &a, const Point &b )
{
	return a.real() * b.imag() - a.imag() * b.real();
}

// テァツ崢エテァツキツ?( p1, p2 ) テ」ツ?ィテァツつケ q テ」ツ?ョティツキツ敕ゥツ崢「
double distance_line_point( const Point &p1, const Point &p2, const Point &q )
{
	return abs( cross( p2 - p1, q - p1 ) ) / abs( ( p2 - p1 ) );
}

// テァツキツ堙・ツ按?( p1, p2 ) テ」ツ?ィテァツつケ q テ」ツ?ョティツキツ敕ゥツ崢「
double distance_segment_point( const Point &p1, const Point &p2, const Point q )
{
	if ( EPS < dot( p2 - p1, q - p1 ) && EPS < dot( p1 - p2, q - p2 ) ) // テ・ツ楪づァツキツ堙」ツ?古、ツコツ、テ」ツつ湘」ツつ?
	{
		return distance_line_point( p1, p2, q );
	}
	else
	{
		return min( abs( p1 - q ), abs( p2 - q ) );
	}
}

// テァツキツ堙・ツ按?( p1, p2 ) テ」ツ?ォテァツつケ q テ」ツ?古、ツケツ療」ツ?」テ」ツ?ヲテ」ツ??」ツつ凝」ツ??
bool segment_point_intersect( const Point &p1, const Point &p2, const Point &q )
{
	// テァツォツッテァツつケテ」ツ?凝」ツつ嘉」ツ?ョ q テ」ツ?クテ」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?ョテ・ツ、ツ姪ァツゥツ催」ツ??0 テ「ツ??テァツォツッテァツつケテ」ツ?凝」ツつ嘉」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?古、ツクツヲティツ。ツ?テ「ツ??テァツ崢エテァツキツ?( p1, p2 ) テ」ツ?ォテァツつケ q テ」ツ?古、ツケツ療」ツつ?
	// q テ」ツ?凝」ツつ嘉ァツォツッテァツつケテ」ツ?クテ」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?ョテ・ツ??ァツゥツ催」ツ??0 テ、ツサツ・テ、ツクツ?テ「ツ??テァツつケ p テ」ツ??p1, p2 テ」ツ?ョテ・ツ??・ツ?エテ」ツ?ォテ」ツ?づ」ツつ?
	return abs( cross( p1 - q, p2 - q ) ) <= EPS && dot( p1 - q, p2 - q ) <= EPS;
}

// テァツ崢エテァツキツ?( p1, p2 ) テ」ツ?ィテァツ崢エテァツキツ?( q1, q2 ) テ」ツ?ョテ、ツコツ、テァツつケ
Point lines_intersection( const Point &p1, const Point &p2, const Point &q1, const Point &q2 )
{
	return p1 + ( p2 - p1 ) * ( cross( q2 - q1, q1 - p1 ) / cross( q2 - q1, p2 - p1 ) );
}

// テァツキツ堙・ツ按?( p1, p2 ) テ」ツ?ィテァツキツ堙・ツ按?( q1, q2 ) テ」ツ?古、ツコツ、テ・ツキツョテ」ツ?凖」ツつ凝」ツ??
bool segments_intersect( const Point &p1, const Point &p2, const Point &q1, const Point &q2 )
{		
	if ( abs( cross( p1 - p2, q1 - q2 ) ) <= EPS ) // テ、ツコツ古ァツ崢エテァツキツ堙」ツ?古、ツクツヲティツ。ツ古」ツ?ェテ・ツ?エテ・ツ青?
	{
		// テァツ可?ヲツ鳴ケテ」ツ?ョテァツキツ堙・ツ按?」ツ?ォテ、ツサツ姪ヲツ鳴ケテ」ツ?ョテァツォツッテァツつケテ」ツ?古、ツケツ療」ツつ凝」ツ??
		return segment_point_intersect( p1, p2, q1 ) ||
			   segment_point_intersect( p1, p2, q2 ) ||
			   segment_point_intersect( q1, q2, p1 ) ||
			   segment_point_intersect( q1, q2, p2 );
	}
	else
	{
		// テ、ツコツ古ァツ崢エテァツキツ堙」ツ?ョテ、ツコツ、テァツつケテ」ツ?古、ツクツ。テヲツ鳴ケテ」ツ?ョテァツキツ堙・ツ按?」ツ?ォテ、ツケツ療」ツつ凝」ツ??
		Point r( lines_intersection( p1, p2, q1, q2 ) );
		return segment_point_intersect( p1, p2, r ) && segment_point_intersect( q1, q2, r );
	}
}

double maxRadius( const Point &s, const Point &g, const Point &p, const double h )
{
	const double dist_ground = distance_segment_point( s, g, p );

	if ( dist_ground - EPS <= h )
	{
		return dist_ground;
	}

	double lb = 0, ub = 1000;
	const Point top = Point( dist_ground, h );
	REP( times, 0, 1000 )
	{
		const double mid = ( lb + ub ) / 2;
		const Point center = Point( 0, mid );

		if ( abs( center - top ) < mid - EPS )
		{
			ub = mid;
		}
		else
		{
			lb = mid;
		}
	}

	return lb;
}

double solve( const Point &s, const Point &g, const vector<Point> &pmin, const vector<Point> &pmax, const vector<double> &hs )
{
	const int N = pmin.size();
	vector< vector<Point> > ps( N );
	REP( i, 0, N )
	{
		ps[i].PB( Point( pmin[i].real(), pmin[i].imag() ) );
		ps[i].PB( Point( pmax[i].real(), pmin[i].imag() ) );
		ps[i].PB( Point( pmax[i].real(), pmax[i].imag() ) );
		ps[i].PB( Point( pmin[i].real(), pmax[i].imag() ) );
	}

	// テァツオツ古ィツキツッテ」ツ?ョテ、ツクツ甘」ツ?ォテ」ツδ姪」ツδュテ」ツδε」ツつッ
	REP( i, 0, N )
	{
		REP( j, 0, 4 )
		{
			if ( segments_intersect( s, g, ps[i][j], ps[i][ ( j + 1 ) % 4 ] ) )
			{
				return 0;
			}
		}
	}

	// テ・ツァツ凝ァツつケテ」ツδサテァツオツづァツつケテ」ツ?古」ツδ姪」ツδュテ」ツδε」ツつッテ」ツ?ョテ、ツクツ?
	{
		vector<Point> sg;
		sg.PB( s );
		sg.PB( g );
		REP( i, 0, N )
		{
			REP( j, 0, 2 )
			{
				if ( pmin[i].real() - EPS <= sg[j].real() && sg[j].real() <= pmax[i].real() + EPS && 
						pmin[i].imag() - EPS <= sg[j].imag() && sg[j].imag() <= pmax[i].imag() + EPS )
				{
					return 0;
				}
			}
		}
	}

	double res = 1000;
	REP( i, 0, N )
	{
		REP( j, 0, 4 )
		{
			res = min( res, maxRadius( s, g, ps[i][j], hs[i] ) );
			res = min( res, maxRadius( ps[i][j], ps[i][ ( j + 1 ) % 4 ], s, hs[i] ) );
			res = min( res, maxRadius( ps[i][j], ps[i][ ( j + 1 ) % 4 ], g, hs[i] ) );
		}
	}
	return res;
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 8 ) << fixed;

	for ( int n; cin >> n, n; )
	{
		Point s, g;
		cin >> s >> g;

		vector<Point> pmin( n ), pmax( n );
		vector<double> hs( n );
		REP( i, 0, n )
		{
			cin >> pmin[i] >> pmax[i] >> hs[i];
		}

		cout << solve( s, g, pmin, pmax, hs ) << endl;
	}

	return 0;
}