#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <iostream>

using namespace std;

//FILE *in = freopen("input.txt", "r", stdin);

typedef long double ld;
const ld EPS=1e-10;

struct Point{
	Point(ld x,ld y):x(x), y(y){}
	Point(){}
	ld x,y;
};

Point operator+(const Point &a, const Point &b){
	return Point(a.x+b.x, a.y+b.y);
}

Point operator-(const Point &a, const Point &b){
	return Point(a.x-b.x, a.y-b.y);
}

Point operator*(const Point &a, const ld b){
	return Point(a.x*b, a.y*b);
}

ld cross(const Point &a, const Point &b){
	return a.x*b.y - a.y*b.x;
}

ld dot(const Point &a, const Point &b){
	return a.x*b.x+a.y*b.y;
}

ld norm(const Point &a){
	return dot(a,a);
}

ld abs(const Point &a){
	return sqrt(norm(a));
}

struct Line:vector<Point>{
	Line(Point a = Point(0,0), Point b = Point(0,0)){
		this->push_back(a);
		this->push_back(b);
	}
};

int ccw(Point a, Point b, Point c){
	b = b - a;
	c = c - a;
	if(cross(b,c) > EPS) return 1;
	if(cross(b,c) < -EPS) return -1;
	if(dot(b,c) < 0) return 2;
	if(norm(b)<norm(c)) return -2;
	return 0;
}

bool is_intersect_SS(const Line &s, const Line &t){
	return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<= 0 &&
		ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

bool is_intersect_SP(const Line &l, const Point &p){
	return ccw(l[0],l[1],p)==0;
}

Point projection(const Line &l, const Point &p){
	ld t = dot(p-l[0],l[1]-l[0])/norm(l[0]-l[1]);
	return l[0]+(l[1]-l[0])*t;
}

ld distance_SP(const Line &s, const Point &p){
	const Point r = projection(s,p);
	if(is_intersect_SP(s,r))return abs(r-p);
	return min(abs(s[0]-p), abs(s[1]-p));
}

ld distance_SS(const Line &s, const Line &t){
	if(is_intersect_SS(s,t)) return 0;
	return min(min(distance_SP(s,t[0]),distance_SP(s,t[1])),min(distance_SP(t,s[0]),distance_SP(t, s[1])));
}

bool lt(ld x, ld y){
	return x < y+EPS;
}

int n;
Line L;
Line data[100];
int H[100];

ld Max;

void input(){
	int w, x, y, z;
	Max = 1e10;
	scanf("%d%d%d%d", &w, &x, &y, &z);
	L = Line(Point(w,x), Point(y,z));
	for(int i = 0 ; i< n;i++){
		scanf("%d%d%d%d%d", &w, &x, &y, &z, &H[i]);
		data[i] = Line(Point(w,x), Point(y,z));
	}
}

void process(){
	ld minX = min(L[0].x, L[1].x);
	ld minY = min(L[0].y, L[1].y);
	ld maxX = max(L[0].x, L[1].x);
	ld maxY = max(L[0].y, L[1].y);
	//Check rect & line
	for(int i = 0; i < n;i++){
		if(is_intersect_SS(L, Line(Point(data[i][0].x, data[i][0].y), Point(data[i][0].x, data[i][1].y))) ||
			is_intersect_SS(L, Line(Point(data[i][0].x, data[i][0].y), Point(data[i][1].x, data[i][0].y))) ||
			is_intersect_SS(L, Line(Point(data[i][0].x, data[i][1].y), Point(data[i][1].x, data[i][1].y))) ||
			is_intersect_SS(L, Line(Point(data[i][1].x, data[i][0].y), Point(data[i][1].x, data[i][1].y)))) {
			printf("0.0000\n");
			return;
		}

		if(lt(data[i][0].x , minX) && lt(data[i][0].y , minY) && lt(maxX , data[i][1].x) && lt(maxY , data[i][1].y)) {
			printf("0.0000\n");
			return;
		}
	}

	//get r;
	for(int i = 0; i < n; i++) {
		{
			ld d = distance_SS(L, Line(Point(data[i][0].x, data[i][0].y), Point(data[i][0].x, data[i][1].y)));
			if(lt(d, H[i])) {
				if(lt(d, Max)) Max = d;
			}
			else{
				ld r = ((ld)(H[i]*H[i]) + (ld)(d*d))/((ld)2.0*H[i]);
				if(lt(r, Max)) Max = r;
			}
		}
		{
			ld d = distance_SS(L, Line(Point(data[i][0].x, data[i][0].y), Point(data[i][1].x, data[i][0].y)));
			if(lt(d, H[i])) {
				if(lt(d, Max)) Max = d;
			}
			else{
				ld r = ((ld)(H[i]*H[i]) + (ld)(d*d))/((ld)2.0*H[i]);
				if(lt(r,Max)) Max = r;
			}
		}
		{
			ld d = distance_SS(L, Line(Point(data[i][0].x, data[i][1].y), Point(data[i][1].x, data[i][1].y)));
			if(lt(d, H[i])) {
				if(lt(d, Max)) Max = d;
			}
			else{
				ld r = ((ld)(H[i]*H[i]) + (ld)(d*d))/((ld)2.0*H[i]);
				if(lt(r,Max)) Max = r;
			}
		}
		{
			ld d = distance_SS(L, Line(Point(data[i][1].x, data[i][0].y), Point(data[i][1].x, data[i][1].y)));
			if(lt(d, H[i])) {
				if(lt(d, Max)) Max = d;
			}
			else{
				ld r = ((ld)(H[i]*H[i]) + (ld)(d*d))/((ld)2.0*H[i]);
				if(lt(r,Max)) Max = r;
			}
		}
	}
	printf("%.4llf\n", Max);
}

int main() {
	while(true){
		scanf("%d", &n);
		if(n==0)break;
		input();
		process();
	}
	return 0;
}

Measured memory_bytes: 1224