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

const double EPS = 1e-10;
enum POSITION {FORWARD = -2, UNDER, ON, ABOVE, BACKWARD};   // ccw(a, b, p)で3点a, b, pの位置関係を返す
                                                            //   0: a-p-b, 2: p-a-b, -2: a-b-p, 1: -a-b-の上にp, -1: -a-b-の下にp
// class
class Point;
class Segment;
class Line;
class Circle;
// member
class Point {
    double x_value, y_value;
public:
    Point() :x_value(0.0), y_value(0.0) {}
    Point(double d) :x_value(d), y_value(d) {}
    Point(double a, double b) :x_value(a), y_value(b) {}
    double x() const {return x_value;}
    double y() const {return y_value;}
    double x(double d) {return x_value = d;}
    double y(double d) {return y_value = d;}
    bool operator== (const Point&) const;
    bool operator!= (const Point&) const;
    bool operator< (const Point&) const;
    bool operator> (const Point&) const;
    bool operator<= (const Point&) const;
    bool operator>= (const Point&) const;
    const Point operator-() const;
    const Point& operator=(const Point&);
    const Point& operator+=(const Point&);
    const Point& operator-=(const Point&);
    const Point& operator*=(const Point&);
    const Point& operator/=(const Point&);
    double dot(const Point&) const;
    double cross(const Point&) const;
    double abs() const;
    double norm() const;
    double distance(const Point&) const;
    double distance(const Segment&) const;
    double distance(const Line&) const;
    bool intersect(const Point&) const;
    bool intersect(const Segment&) const;
    bool intersect(const Line&) const;
    const Point projection(const Line&) const;
    const Point reflection(const Line&) const;
    POSITION ccw(const Point&, const Point&) const;
};
const Point operator+(const Point& lhs, const Point& rhs);
const Point operator-(const Point& lhs, const Point& rhs);
const Point operator*(const Point& lhs, const Point& rhs);
const Point operator/(const Point& lhs, const Point& rhs);
class Segment {
    Point source_point, target_point;
public:
    Segment(const Point& a = Point(),const Point& b = Point()) :source_point(a), target_point(b) {}
    const Point& source() const {return source_point;}
    const Point& target() const {return target_point;}
    const Point& source(const Point& p) {return source_point = p;}
    const Point& target(const Point& p) {return target_point = p;}
    const Line line() const;
    double distance(const Point&) const;
    double distance(const Segment&) const;
    double distance(const Line&) const;
    bool intersect(const Point&) const;
    bool intersect(const Segment&) const;
    bool intersect(const Line&) const;
};
class Line {
    Point source_point, target_point;
public:
    Line(const Point& a = Point(), const Point& b = Point()) :source_point(a), target_point(b) {}
    const Point& source() const {return source_point;}
    const Point& target() const {return target_point;}
    const Point& source(const Point& p) {return source_point = p;}
    const Point& target(const Point& p) {return target_point = p;}
    const Segment segment() const;
    double distance(const Point&) const;
    double distance(const Segment&) const;
    double distance(const Line&) const;
    bool intersect(const Point&) const;
    bool intersect(const Segment&) const;
    bool intersect(const Line&) const;
    const Point projection(const Point&) const;
    const Point reflection(const Point&) const;
    const Point crosspoint(const Line&) const;
};
class Circle {
    Point center_point;
    double radius;
public:
    Circle(double a = 0.0, double b = 0.0, double c = 0.0) :center_point(Point(a, b)), radius(c) {}
    const Point& center() const {return center_point;}
    double x() const {return center_point.x();}
    double y() const {return center_point.y();}
    double r() const {return radius;}
    const Point& center(const Point& p) {return center_point = p;}
    double x(double d) {return center_point.x(d);}
    double y(double d) {return center_point.y(d);}
    double r(double d) {return radius = d;}
    bool include(const Point&) const;
    bool include(const Circle&) const;
    bool intersect(const Circle&) const;
    vector<Point> crosspoint(const Circle&) const;
};
// Point
bool Point::operator== (const Point &p) const {return x() == p.x() && y() == p.y();}
bool Point::operator!= (const Point &p) const {return x() != p.x() || y() != p.y();}
bool Point::operator<(const Point &p) const {return x() != p.x() ? x() < p.x() : y() < p.y();}
bool Point::operator>(const Point &p) const {return x() != p.x() ? x() > p.x() : y() > p.y();}
bool Point::operator<=(const Point &p) const {return x() != p.x() ? x() < p.x() : y() <= p.y();}
bool Point::operator>=(const Point &p) const {return x() != p.x() ? x() > p.x() : y() >= p.y();}
const Point operator+(const Point& lhs, const Point& rhs) {return Point(lhs.x() + rhs.x(), lhs.y() + rhs.y());}
const Point operator-(const Point& lhs, const Point& rhs) {return Point(lhs.x() - rhs.x(), lhs.y() - rhs.y());}
const Point operator*(const Point& lhs, const Point& rhs) {return Point(lhs.x() * rhs.x(), lhs.y() * rhs.y());}
const Point operator/(const Point& lhs, const Point& rhs) {return Point(lhs.x() / rhs.x(), lhs.y() / rhs.y());}
const Point Point::operator-() const {return Point(-x(), -y());}
const Point& Point::operator=(const Point& p) {x(p.x()); y(p.y()); return *this;}
const Point& Point::operator+=(const Point& p) {return *this = *this + p;}
const Point& Point::operator-=(const Point& p) {return *this = *this - p;}
const Point& Point::operator*=(const Point& p) {return *this = *this * p;}
const Point& Point::operator/=(const Point& p) {return *this = *this / p;}
double Point::dot(const Point& p) const {return x() * p.x() + y() * p.y();}
double Point::cross(const Point& p) const {return x() * p.y() - y() * p.x();}
double Point::abs() const {return hypot(x(), y());}
double Point::norm() const {return x() * x() + y() * y();}
double Point::distance(const Point& p) const {return (p - (*this)).abs();}
double Point::distance(const Segment& s) const {return s.distance(*this);}
double Point::distance(const Line& l) const {return l.distance(*this);}
bool Point::intersect(const Point& p) const {return *this == p;}
bool Point::intersect(const Segment& s) const {return s.intersect(*this);}
bool Point::intersect(const Line& l) const {return l.intersect(*this);}
const Point Point::projection(const Line& l) const {return l.projection(*this);}
const Point Point::reflection(const Line& l) const {return l.reflection(*this);}
POSITION Point::ccw(const Point& b, const Point& p) const {
    const Point& a = *this;
    Point v1 = b - a;
    Point v2 = p - a;
    if(v1.cross(v2) > EPS) return ABOVE;
    if(v1.cross(v2) < -EPS) return UNDER;
    if(v1.dot(v2) < -EPS) return BACKWARD;
    if(v2.norm() - v1.norm() > EPS) return FORWARD;
    return ON;
}
// Segment
const Line Segment::line() const {return Line(source(), target());}
double Segment::distance(const Point& p) const {
    Point q = line().projection(p);
    if(intersect(q)) return q.distance(p);
    double a = source().distance(p);
    double b = target().distance(p);
    return a < b ? a : b;
}
double Segment::distance(const Segment& s) const {
    if(intersect(s)) return 0.0;
    double a = distance(s.source());
    double b = distance(s.target());
    double c = s.distance(source());
    double d = s.distance(target());
    a = a < b ? a : b;
    a = a < c ? a : c;
    return a < d ? a : d;
}
double Segment::distance(const Line& l) const {return l.distance(*this);}
bool Segment::intersect(const Point& p) const {
    return source().distance(p) + target().distance(p) - target().distance(source()) <= EPS;
}
bool Segment::intersect(const Segment& s) const {
    bool a = s.source().ccw(s.target(), source()) * s.source().ccw(s.target(), target()) <= EPS;
    bool b = source().ccw(target(), s.source()) * source().ccw(target(), s.target()) <= EPS;
    return a && b;
}
bool Segment::intersect(const Line& l) const {return l.intersect(*this);}
// Line
const Segment Line::segment() const {return Segment(source(), target());}
double Line::distance(const Point& p) const {return p.distance(projection(p));}
double Line::distance(const Segment& s) const {
    if(intersect(s)) return 0.0;
    double a = distance(s.source());
    double b = distance(s.target());
    return a < b ? a : b;
}
double Line::distance(const Line& l) const {return intersect(l) ? 0.0 : distance(l.source());}
bool Line::intersect(const Point& p) const {
    Point v1 = source() - p;
    Point v2 = target() - p;
    return fabs(v2.cross(v1)) < EPS;
}
bool Line::intersect(const Segment& s) const {
    Point v1 = target() - source();
    Point v2 = s.source() - source();
    Point v3 = s.target() - source();
    return v1.cross(v2) * v1.cross(v3) <= EPS;
}
bool Line::intersect(const Line& l) const {
    Point v1 = target() - source();
    Point v2 = l.target() - l.source();
    Point v3 = l.source() - source();
    return fabs(v1.cross(v2)) > EPS || fabs(v1.cross(v3)) < EPS;
}
const Point Line::projection(const Point& p) const {
    Point v1 = p - source();
    Point v2 = source() - target();
    return Point(source() + v2 * (v1.dot(v2) / v2.norm()));
}
const Point Line::reflection(const Point& p) const {
    return p + (projection(p) - p) * 2.0;
}
const Point Line::crosspoint(const Line& l) const {
    Point v1 = target() - source();
    Point v2 = l.target() - l.source();
    Point v3 = target() - l.source();
    double a = v1.cross(v2);
    double b = v1.cross(v3);
    if(fabs(a) <= EPS && fabs(b) <= EPS) l.source();
    return l.source() + v2 * (b / a);
}

double max_radius(Segment& course, vector<Point>& block, double h) {
    double result = 1e10;

    vector<Segment> edge;
    for(int i = 0; i < block.size(); ++i) edge.push_back(Segment(block[i], block[(i + 1) % block.size()]));

    for(auto& e: edge) {
        if(e.intersect(course)) return 0.0;
    }
    for(auto& point: block) {
        double d = point.distance(course);
        result = min(result, d > h ? (h * h + d * d) / (2.0 * h) : d);
    }
    for(auto& e: edge) for(auto& point: {course.target(), course.source()}) {
        double d = point.distance(e);
        result = min(result, d > h ? (h * h + d * d) / (2.0 * h) : d);
    }

    return result;
}

int main () {
    int N;
    while(cin >> N, N) {
        double answer = 1e10;
        double sx, sy, ex, ey;
        cin >> sx >> sy >> ex >> ey;
        Segment course(Point(sx, sy), Point(ex, ey));
        for(int i = 0; i < N; ++i) {
            double minx, miny, maxx, maxy, h;
            cin >> minx >> miny >> maxx >> maxy >> h;
            vector<Point> block;
            block.push_back(Point(minx, miny));
            block.push_back(Point(minx, maxy));
            block.push_back(Point(maxx, miny));
            block.push_back(Point(maxx, maxy));
            answer = min(answer, max_radius(course, block, h));
        }
        cout << answer << endl;
    }
};

Measured memory_bytes: 1308