#include <bits/stdc++.h>
using namespace std;
double INF = 1000000;
double EPS = 0.000000001;
int sign(double x){
  if (x >= EPS){
    return 1;
  } else if (x <= - EPS){
    return -1;
  } else {
    return 0;
  }
}
struct point{
  double x, y;
  point(){
  }
  point(double x, double y): x(x), y(y){
  }
  point operator +(point P){
    return point(x + P.x, y + P.y);
  }
  point operator -(point P){
    return point(x - P.x, y - P.y);
  }
  point operator *(double k){
    return point(x * k, y * k);
  }
  point operator /(double k){
    return point(x / k, y / k);
  }
};
double abs(point P){
  return sqrt(pow(P.x, 2) + pow(P.y, 2));
}
double dist(point P, point Q){
  return abs(Q - P);
}
double dot(point P, point Q){
  return P.x * Q.x + P.y * Q.y;
}
double cross(point P, point Q){
  return P.x * Q.y - P.y * Q.x;
}
struct line{
  point A, B;
  line(){
  }
  line(point A, point B): A(A), B(B){
  }
};
point vec(line L){
  return L.B - L.A;
}
double is_parallel(line L1, line L2){
  return sign(cross(vec(L1), vec(L2))) == 0;
}
point line_intersection(line L1, line L2){
  return L1.A + vec(L1) * cross(L2.A - L1.A, vec(L2)) / cross(vec(L1), vec(L2));
}
bool on_segment(point P, line L){
  return sign(dot(P - L.A, vec(L))) > 0 && sign(dot(P - L.B, vec(L))) < 0;
}
double point_line_distance(point P, line L){
  return abs(cross(P - L.A, vec(L))) / abs(vec(L));
}
double point_segment_distance(point P, line L){
  if (sign(dot(P - L.A, vec(L))) < 0){
    return dist(P, L.A);
  } else if (sign(dot(P - L.B, vec(L))) > 0){
    return dist(P, L.B);
  } else {
    return point_line_distance(P, L);
  }
}
double segment_distance(line L1, line L2){
  if (!is_parallel(L1, L2)){
    point P = line_intersection(L1, L2);
    if (on_segment(P, L1) && on_segment(P, L2)){
      return 0;
    }
  }
  double ans = INF;
  ans = min(ans, point_segment_distance(L1.A, L2));
  ans = min(ans, point_segment_distance(L1.B, L2));
  ans = min(ans, point_segment_distance(L2.A, L1));
  ans = min(ans, point_segment_distance(L2.B, L1));
  return ans;
}
int main(){
  cout << fixed << setprecision(20);
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    line L;
    cin >> L.A.x >> L.A.y >> L.B.x >> L.B.y;
    vector<double> x1(N), x2(N), y1(N), y2(N);
    vector<point> A(N), B(N), C(N), D(N);
    vector<double> h(N);
    for (int i = 0; i < N; i++){
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i] >> h[i];
      A[i] = point(x1[i], y1[i]);
      B[i] = point(x1[i], y2[i]);
      C[i] = point(x2[i], y2[i]);
      D[i] = point(x2[i], y1[i]);
    }
    double tv = 0;
    double fv = 1000;
    for (int i = 0; i < 50; i++){
      double mid = (tv + fv) / 2;
      bool ok = true;
      for (int j = 0; j < N; j++){
        double r;
        if (h[j] >= mid){
          r = mid;
        } else {
          r = sqrt(pow(mid, 2) - pow(mid - h[j], 2));
        }
        if (x1[j] <= L.A.x && L.A.x <= x2[j] && y1[j] <= L.A.y && L.A.y <= y2[j]){
          ok = false;
        }
        if (x1[j] <= L.B.x && L.B.x <= x2[j] && y1[j] <= L.B.y && L.B.y <= y2[j]){
          ok = false;
        }
        if (segment_distance(L, line(A[j], B[j])) < r){
          ok = false;
        }
        if (segment_distance(L, line(B[j], C[j])) < r){
          ok = false;
        }
        if (segment_distance(L, line(C[j], D[j])) < r){
          ok = false;
        }
        if (segment_distance(L, line(D[j], A[j])) < r){
          ok = false;
        }
      }
      if (ok){
        tv = mid;
      } else {
        fv = mid;
      }
    }
    cout << tv << endl;
  }
}
