#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }

using Coordinate = double;
const int INF = 1 << 30;
const ll INFL = 1LL << 60;
const double EPS = 1e-8;


bool eq(Coordinate a, Coordinate b) { return abs(a - b) < EPS; }

struct Point {
    Coordinate x,y;
    Point():x(0),y(0){}
    Point(Coordinate x,Coordinate y):x(x),y(y){}
    pair<Coordinate,Coordinate> to_pair() const { return make_pair(x,y); }
    bool operator == (const Point &a) const { return eq(x, a.x) && eq(y, a.y); }
    bool operator != (const Point &a) const { return !(*this == a); }
    
    Point operator + (const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator - () const { return Point(-x, -y); }
    Point& operator += (const Point& p) { x += p.x; y += p.y; return *this; }
    Point& operator -= (const Point& p) { x -= p.x; y -= p.y; return *this; }
    // ???????????¨ x, y???
    bool operator <  (const Point &a) const { return x < a.x && y < a.y; }
    bool operator <= (const Point &a) const { return *this == a || *this < a;}
    bool operator >  (const Point &a) const { return !(*this <= a); }
    bool operator >= (const Point &a) const { return !(*this < a); }
};
template<typename T> Point operator * (T k, const Point &p) { return Point(k * p.x, k * p.y); }
template<typename T> Point operator / (const Point &p, T k) { return Point(p.x / k, p.y / k); }
double dot(const Point &a, const Point &b) { return a.x * b.x + a.y * b.y; }
double cross(const Point &a, const Point &b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt( dot(a, a) ); }

istream &operator >> (istream& is, Point& p){ return is >> p.x >> p.y;}
ostream &operator << (ostream& os, const Point& p){ return os << "(" << p.x << "," << p.y << ")";}

double distance(const Point& a, const Point& b) { return norm(a - b); }

enum class ccw_t {
    COUNTER_CLOCK_WISE = 1,
    CLOCK_WISE = -1,
    STRAIGHT_C_A_B = 2,
    STRAIGHT_A_B_C = -2,
    STRAIGHT_A_C_B = 0
};


ccw_t ccw(const Point &a, const Point &b, const Point &c){
    Point ab = b - a;
    Point ac = c - a;
    if( cross(ab,ac) > 0 ) return ccw_t::COUNTER_CLOCK_WISE;//a-b-c ???????¨???????
    if( cross(ab,ac) < 0 ) return ccw_t::CLOCK_WISE;        //a-b-c ????¨???????
    if( dot(ab,ac) < 0 ) return ccw_t::STRAIGHT_C_A_B;      //c-a-b
    if( norm(ab) < norm(ac) )return ccw_t::STRAIGHT_A_B_C;  //a-b-c or a==b
    return ccw_t::STRAIGHT_A_C_B;                           //a-c-b or b==c or a==c
}


struct Segment{
    Point a, b;
    Segment(){}
    Segment(const Point& a, const Point& b):a(a), b(b){}
    pair<Point,Point> to_pair() const { return make_pair(a,b); }
    bool operator == (const Segment& s) const { return to_pair() == s.to_pair();}
    bool operator != (const Segment& s) const { return to_pair() != s.to_pair();}

    bool on_line(const Point &p) const {
        return ccw(a, b, p) == ccw_t::STRAIGHT_A_C_B;
    }
    Point closest_point(const Point &p) const {
        Point pp = projection(p);
        if(on_line(pp)) return pp;        
        return distance(a, p) < distance(b, p) ? a : b;
    }
    Point projection(const Point &p) const {
        // cerr << a << b << p << endl;
        double t = dot(p - a, b - a) / norm(b - a);
        // cerr << t << endl;
        Point ret = t * (b - a) / norm(b - a);
        // cerr << ret  << ret + a << endl;
        return ret + a;
    }
};
istream &operator >> (istream& is, Segment& s){ return is >> s.a >> s.b;}
ostream &operator << (ostream& os, Segment& s){ return os << s.a << "->" << s.b;}

double distance( const Segment &s , const Point &p){
    if( dot( s.b - s.a , p - s.a ) < EPS ) return norm( p - s.a );
    if( dot( s.a - s.b , p - s.b ) < EPS ) return norm( p - s.b );
    return abs(cross( s.b - s.a , p - s.a ) / norm( s.b - s.a ));
}

bool does_intersect(const Segment &a, const Segment &b){
    return (int)ccw(a.a, a.b, b.a) * (int)ccw(a.a, a.b, b.b) <= 0 &&
            (int)ccw(b.a, b.b, a.a) * (int)ccw(b.a, b.b, a.b) <= 0;
}



struct Rectangle {
    array<Point, 4> p;
    // order:
    //     3 2
    //     0 1
    Rectangle(const array<Point, 4> &pp):p(pp) {
        rep(i, 3) {            
            repeat(j, i + 1, 4) {
                int cnt = 0;
                rep(k, 4) if(k != i and k != j){
                    cnt += ccw(p[i], p[j], p[k]) == ccw_t::COUNTER_CLOCK_WISE;
                }
                if(cnt == 2) {
                    swap(p[i + 1], p[j]);
                    break;
                }
            } 
        }
    }
    bool intersect(const Segment &s) const {
        bool res = false;
        rep(i, 4) res |= does_intersect(s, Segment(p[i], p[(i + 1) % 4]));
        return res;
    }
    bool contain(const Point &pp) const {
        bool flg = true;
        rep(i, 4) flg &= ccw(p[i], p[(i + 1) % 4], pp) == ccw_t::COUNTER_CLOCK_WISE;
        return flg;
    }
    bool contain(const Segment &s) const {
        return contain(s.a) and contain(s.b);
    }
    Point closest_point(const Point &pp) const {
        Point res = p[0];
        rep(i, 4) {
            Segment s = Segment(p[i], p[(i+1)%4]);
            Point ppp = s.closest_point(pp);
            if(distance(res, pp) > distance(ppp, pp)) res = ppp;
        }
        return res;
    }
    Point closest_point(const Segment &s) const {
        Point res = p[0];
        repeat(i, 1, 4) if(distance(s, res) > distance(s, p[i])) res = p[i];
        for(Point pp : {s.a, s.b}) {
            Point ppp = closest_point(pp);
            if(distance(s, res) > distance(s, ppp)) res = ppp;
        }
        return res;
    }
};


class Solver {
  public:
    Segment S;
    vector<Point> minP, maxP;
    vector<double> H;
    bool solve() {

        int N; cin >> N;
        if(not N) return false;
        cin >> S;
        minP.resize(N);
        maxP.resize(N);
        H.resize(N);
        rep(i, N) cin >> minP[i] >> maxP[i] >> H[i];
        
        double max_r = INF;

        rep(i, N) {            
            Rectangle rect({minP[i], maxP[i], Point(minP[i].x, maxP[i].y), Point(maxP[i].x, minP[i].y)});

            // check cross or contain
            if(rect.intersect(S) or rect.contain(S)) {
                cout << 0 << endl;
                return true;
            }

            rep(i, 4) {
                Segment s(rect.p[i], rect.p[(i+1)%4]);
                Point p1 = s.projection(S.a);
                Point p2 = s.projection(S.b);
            }

            Point closest = rect.closest_point(S);
            double d = distance(S, closest);
            double r = (d * d + H[i] * H[i]) / (2 * H[i]);
            if(r < H[i]) r = d;
            set_min(max_r, r);
        }

        cout << max_r << endl;
        return true;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        Solver s;
        if(not s.solve()) break;
    }
    return 0;
}

Measured memory_bytes: 3288