#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

class point2d {
public:
	double x, y;
	point2d() : x(0), y(0) {};
	point2d(double x_, double y_) : x(x_), y(y_) {};
	bool operator==(const point2d& p) { return x == p.x && y == p.y; }
	bool operator!=(const point2d& p) { return x != p.x || y != p.y; }
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d& operator*=(const double v) { x *= v; y *= v; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	point2d operator*(const double v) const { return point2d(*this) *= v; }
	double norm() { return x * x + y * y; }
	double abs() { return std::sqrt(x * x + y * y); }
	double dot(const point2d& p) { return x * p.x + y * p.y; }
	double cross(const point2d& p) { return x * p.y - y * p.x; }
	int ccw(const point2d& p1, const point2d& p2) {
		// RETURNS: P0 -> P1 -> P2 IS COLLINEAR --> ((P0, P1, P2) IS CENTER --> (2, -2, 0)), COUNTER-CLOCKWISE --> 1, CLOCKWISE --> -1
		point2d pr1 = p1 - point2d(*this);
		point2d pr2 = p2 - point2d(*this);
		if (pr1.cross(pr2) != 0) return pr1.cross(pr2) > 0 ? 1 : -1;
		if (pr1.dot(pr2) < 0) return 2;
		return pr1.norm() < pr2.norm() ? -2 : 0;
	}
};
class segment2d {
public:
	point2d p1, p2;
	segment2d() : p1(point2d()), p2(point2d()) {};
	segment2d(const point2d& p1_, const point2d& p2_) : p1(p1_), p2(p2_) {};
	double norm() { return (p1 - p2).norm(); }
	double abs() { return (p1 - p2).abs(); }
};
double distance(point2d p, segment2d s) {
	double d1 = (p - s.p1).norm();
	double d2 = (p - s.p2).norm();
	double d0 = s.norm();
	if (d0 + d1 < d2 || d0 + d2 < d1) return std::sqrt(std::min(d1, d2));
	return std::abs((p - s.p1).cross(s.p2 - s.p1)) / std::sqrt(d0);
}
bool intersect(segment2d s1, segment2d s2) {
	return s1.p1.ccw(s1.p2, s2.p1) * s1.p1.ccw(s1.p2, s2.p2) <= 0 && s2.p1.ccw(s2.p2, s1.p1) * s2.p1.ccw(s2.p2, s1.p2) <= 0;
}

int N; point2d sx, sy, L[100], R[100], P1[100], P2[100], P3[100], P4[100]; long double h[100];

int main() {
	while (true) {
		cin >> N; if (N == 0) break;
		cin >> sx.x >> sx.y >> sy.x >> sy.y;
		for (int i = 0; i < N; i++) {
			cin >> L[i].x >> L[i].y >> R[i].x >> R[i].y >> h[i];
			P1[i] = point2d{ L[i].x,L[i].y };
			P2[i] = point2d{ L[i].x,R[i].y };
			P3[i] = point2d{ R[i].x,R[i].y };
			P4[i] = point2d{ R[i].x,L[i].y };
		}
		long double minx = 1e9;
		for (int i = 0; i < N; i++) {
			long double V01 = distance(P1[i], segment2d(sx, sy));
			long double V02 = distance(P2[i], segment2d(sx, sy));
			long double V03 = distance(P3[i], segment2d(sx, sy));
			long double V04 = distance(P4[i], segment2d(sx, sy));
			long double V05 = distance(sx, segment2d(P1[i], P2[i]));
			long double V06 = distance(sx, segment2d(P2[i], P3[i]));
			long double V07 = distance(sx, segment2d(P3[i], P4[i]));
			long double V08 = distance(sx, segment2d(P4[i], P1[i]));
			long double V09 = distance(sy, segment2d(P1[i], P2[i]));
			long double V10 = distance(sy, segment2d(P2[i], P3[i]));
			long double V11 = distance(sy, segment2d(P3[i], P4[i]));
			long double V12 = distance(sy, segment2d(P4[i], P1[i]));
			long double V = min({ V01, V02, V03, V04, V05, V06, V07, V08, V09, V10, V11, V12 });

			// 0 になるか判定
			if (L[i].x <= sx.x && sx.x <= R[i].x && L[i].y <= sx.y && sx.y <= R[i].y) V = 0;
			if (L[i].x <= sy.x && sy.x <= R[i].x && L[i].y <= sy.y && sy.y <= R[i].y) V = 0;
			if (intersect(segment2d(sx, sy), segment2d(P1[i], P2[i])) == true) V = 0;
			if (intersect(segment2d(sx, sy), segment2d(P2[i], P3[i])) == true) V = 0;
			if (intersect(segment2d(sx, sy), segment2d(P3[i], P4[i])) == true) V = 0;
			if (intersect(segment2d(sx, sy), segment2d(P4[i], P1[i])) == true) V = 0;

			long double score = 0;
			if (V <= h[i]) score = V;
			else {
				score = V * V / (2.0L * h[i]) + (0.5L * h[i]);
			}
			minx = min(minx, score);
		}
		printf("%.12Lf\n", minx);
	}
	return 0;
}


Measured memory_bytes: 3308