#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	double min_x,min_y,max_x,max_y,h;
};

int N;
Info info[50];
double start_x,start_y,end_x,end_y;

struct Point{
	double x,y;
};

typedef Point Vector;

struct Segment{
	void set(double x1,double y1,double x2,double y2){
		p1.x = x1;
		p1.y = y1;
		p2.x = x2;
		p2.y = y2;
	}
	Point p1,p2;
};

typedef Segment Line;

int func(double x1,double y1,double x2, double y2, double xp, double yp){
	double naiseki,norm1,norm2,gaiseki;
	norm1 = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	norm2 = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
	naiseki = (xp-x1)*(x2-x1)+(yp-y1)*(y2-y1);
	gaiseki = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1);
	if(gaiseki > EPS){
		return 1;
	}else if(gaiseki < -EPS){
		return -1;
	}
	if(naiseki < -EPS){
		return 2;
	}

	if(norm1 < norm2){
		return -2;
	}
	return 0;
}

double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
	return a.x*b.x + a.y*b.y;
}

Point calc_minus(Point a,Point b){
	Point ret;

	ret.x = a.x-b.x;
	ret.y = a.y-b.y;

	return ret;
}

double calc_len(Vector a){
	return sqrt(a.x*a.x+a.y*a.y);
}

double getDistanceLP(Line l,Point p){
	return fabs(cross(calc_minus(l.p2,l.p1),calc_minus(p,l.p1))/calc_len(calc_minus(l.p2,l.p1)));
}

double getDistanceSP(Segment s,Point p){
	if(dot(calc_minus(s.p2,s.p1),calc_minus(p,s.p1)) < 0.0)return calc_len(calc_minus(p,s.p1));
	if(dot(calc_minus(s.p1,s.p2),calc_minus(p,s.p2)) < 0.0)return calc_len(calc_minus(p,s.p2));
	return getDistanceLP(s,p);
}

double getDistance(Segment s1,Segment s2){
	return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
			min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}

void solve(){

	scanf("%lf %lf %lf %lf",&start_x,&start_y,&end_x,&end_y);

	Segment base_seg;
	base_seg.set(start_x,start_y,end_x,end_y);

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf %lf %lf",&info[i].min_x,&info[i].min_y,&info[i].max_x,&info[i].max_y,&info[i].h);
	}

	double R = 1000.0;

	Segment A,B,C,D;
	double tmp_dist;

	for(int i = 0; i < N; i++){

		if(start_x > info[i].min_x && end_x > info[i].min_x && start_x < info[i].max_x && end_x < info[i].max_x &&
				start_y > info[i].min_y && end_y > info[i].min_y && start_y < info[i].max_y && end_y < info[i].max_y){
			printf("0.0000\n");
			return;
		}

		if((func(start_x,start_y,end_x,end_y,info[i].min_x,info[i].min_y)*func(start_x,start_y,end_x,end_y,info[i].min_x,info[i].max_y) <= 0 &&
				func(info[i].min_x,info[i].min_y,info[i].min_x,info[i].max_y,start_x,start_y) * func(info[i].min_x,info[i].min_y,info[i].min_x,info[i].max_y,end_x,end_y) <= 0) ||
				(func(start_x,start_y,end_x,end_y,info[i].min_x,info[i].max_y)*func(start_x,start_y,end_x,end_y,info[i].max_x,info[i].max_y) <= 0 &&
				func(info[i].min_x,info[i].max_y,info[i].max_x,info[i].max_y,start_x,start_y) * func(info[i].min_x,info[i].max_y,info[i].max_x,info[i].max_y,end_x,end_y) <= 0) ||
				(func(start_x,start_y,end_x,end_y,info[i].max_x,info[i].max_y)*func(start_x,start_y,end_x,end_y,info[i].max_x,info[i].min_y) <= 0 &&
				func(info[i].max_x,info[i].max_y,info[i].max_x,info[i].min_y,start_x,start_y) * func(info[i].max_x,info[i].max_y,info[i].max_x,info[i].min_y,end_x,end_y) <= 0) ||
				(func(start_x,start_y,end_x,end_y,info[i].max_x,info[i].min_y)*func(start_x,start_y,end_x,end_y,info[i].min_x,info[i].min_y) <= 0 &&
				func(info[i].max_x,info[i].min_y,info[i].min_x,info[i].min_y,start_x,start_y) * func(info[i].max_x,info[i].min_y,info[i].min_x,info[i].min_y,end_x,end_y) <= 0)){
			printf("0.0000\n");
			return;
		}else{

			A.set(info[i].min_x,info[i].min_y,info[i].min_x,info[i].max_y);
			B.set(info[i].min_x,info[i].max_y,info[i].max_x,info[i].max_y);
			C.set(info[i].max_x,info[i].max_y,info[i].max_x,info[i].min_y);
			D.set(info[i].max_x,info[i].min_y,info[i].min_x,info[i].min_y);

			tmp_dist = min(min(getDistance(base_seg,A),getDistance(base_seg,B)),min(getDistance(base_seg,C),getDistance(base_seg,D)));

			if(info[i].h < tmp_dist){
				R = min(R,(info[i].h*info[i].h+tmp_dist*tmp_dist)/(2*info[i].h));
			}else{
				R = min(R,tmp_dist);
			}
		}
	}

	printf("%.4lf\n",R);
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		solve();
	}

	return 0;
}

Measured memory_bytes: 3156