import java.util.Scanner; public class E { static final double EPS = 1.0e-5; public static void main(String[] args) { Scanner in = new Scanner(System.in); while (true) { int n = in.nextInt(); if (n == 0) break; double ans = Double.MAX_VALUE; V s1 = new V(); s1.x = in.nextDouble(); s1.y = in.nextDouble(); V s2 = new V(); s2.x = in.nextDouble(); s2.y = in.nextDouble(); for (int i = 0; i < n; i++) { double x1 = in.nextDouble(); double y1 = in.nextDouble(); double x2 = in.nextDouble(); double y2 = in.nextDouble(); double h = in.nextDouble(); if (isCollSegs(s1, s2, new V(x1, y1), new V(x2, y2))) { ans = 0; } else if (isCollSegs(s1, s2, new V(x1, y2), new V(x2, y1))) { ans = 0; } double d = segPoint(s1, s2, new V(x1, y1)); double r = Math.min(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(s1, s2, new V(x1, y2)); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(s1, s2, new V(x2, y1)); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(s1, s2, new V(x2, y2)); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x1, y1), new V(x2, y1), s1); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x1, y1), new V(x2, y1), s2); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x1, y1), new V(x1, y2), s1); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x1, y1), new V(x1, y2), s2); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x2, y1), new V(x2, y2), s1); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x2, y1), new V(x2, y2), s2); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x1, y2), new V(x2, y2), s1); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); d = segPoint(new V(x1, y2), new V(x2, y2), s2); r = Math.max(d, (d * d + h * h) / (2 * h)); ans = Math.min(r, ans); } System.out.printf("%.5f%n", ans); } } static double segPoint(V a, V b, V p) { V t1 = b.sub(a); V t2 = p.sub(a); if (t1.dot(t2) < EPS) return t2.length(); t1 = a.sub(b); t2 = p.sub(b); if (t1.dot(t2) < EPS) return t2.length(); return Math.abs(t1.cross(t2) / t1.length()); } static boolean isCollSegs(V a1, V a2, V b1, V b2) { V t1 = a2.sub(a1); V t2 = b1.sub(a1); V t3 = b2.sub(a1); double m1 = t1.cross(t2) * t1.cross(t3); t1 = b2.sub(b1); t2 = a1.sub(b1); t3 = a2.sub(b1); double m2 = t1.cross(t2) * t1.cross(t3); return m1 < EPS && m2 < EPS; } } class V { double x, y; public V() { } public V(double x, double y) { this.x = x; this.y = y; } V sub(V v) { return new V(x - v.x, y - v.y); } double length() { return Math.sqrt(x * x + y * y); } double dot(V v) { return x * v.x + y * v.y; } double cross(V v) { return x * v.y - y * v.x; } }