#!/usr/bin/ruby
#
# 1157.rb: Roll-A-Big-Ball
#

### constant

INF = Float::INFINITY

### subroutines

def i_prod(vx0, vy0, vx1, vy1)
  vx0 * vx1 + vy0 * vy1
end

def o_prod(vx0, vy0, vx1, vy1)
  vx0 * vy1 - vy0 * vx1
end

def d2_p_seg(px, py, x0, y0, x1, y1)
  dx01 = x1 - x0
  dy01 = y1 - y0
  dx0p = px - x0
  dy0p = py - y0
  dx1p = px - x1
  dy1p = py - y1

  return (dx0p ** 2 + dy0p ** 2) if i_prod(dx01, dy01, dx0p, dy0p) <= 0.0
  return (dx1p ** 2 + dy1p ** 2) if i_prod(-dx01, -dy01, dx1p, dy1p) <= 0.0
  o_prod(dx01, dy01, dx0p, dy0p) ** 2 / (dx01 ** 2 + dy01 ** 2)
end

def cross_segs?(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1)
  dax = ax1 - ax0
  day = ay1 - ay0
  dbx = bx1 - bx0
  dby = by1 - by0

  if o_prod(dax, day, dbx, dby) == 0.0
    if ay0 * (ax1 - bx0) + ay1 * (bx0 - ax0) * by0 * (ax0 - ax1) == 0.0 &&
        (i_prod(bx0 - ax0, by0 - ay0, bx1 - ax0, by1 - ax0) <= 0.0 ||
         i_prod(bx0 - ax1, by0 - ay1, bx1 - ax1, by1 - ax1) <= 0.0 ||
         i_prod(ax0 - bx0, ay0 - by0, ax1 - bx0, ay1 - bx0) <= 0.0 ||
         i_prod(ax0 - bx1, ay0 - by1, ax1 - bx1, ay1 - bx1) <= 0.0)
      return true
    end
    return false
  end

  (o_prod(dax, day, bx0 - ax0, by0 - ay0) *
   o_prod(dax, day, bx1 - ax0, by1 - ay0) <= 0.0 &&
   o_prod(dbx, dby, ax0 - bx0, ay0 - by0) *
   o_prod(dbx, dby, ax1 - bx0, ay1 - by0) <= 0.0)
end

### main

loop do
  n = gets.to_i
  break if n == 0

  sx, sy, ex, ey = gets.split.map(&:to_f)
  #p [sx, sy, ex, ey]

  rects = n.times.map{gets.split.map(&:to_f)}
  #p rects

  min_r2 = INF

  rects.each do |minxi, minyi, maxxi, maxyi, hi|
    #p [minxi, minyi, maxxi, maxyi, hi]

    pts = [[minxi, minyi], [maxxi, minyi], [maxxi, maxyi], [minxi, maxyi]]

    incl = true
    min_d2 = INF

    for i in (0...4)
      j = (i + 1) % 4

      xi, yi = pts[i]
      xj, yj = pts[j]

      if incl
        if o_prod(xj - xi, yj - yi, sx - xi, sy - yi) < 0.0 ||
            o_prod(xj - xi, yj - yi, ex - xi, ey - yi) < 0.0
          incl = false
        end
      end

      if cross_segs?(sx, sy, ex, ey, xi, yi, xj, yj)
        #p ['cross_segs?', sx, sy, ex, ey, xi, yi, xj, yj]
        min_d2 = 0.0
        break
      end

      min_d2 = [min_d2,
                d2_p_seg(sx, sy, xi, yi, xj, yj),
                d2_p_seg(ex, ey, xi, yi, xj, yj),
                d2_p_seg(xi, yi, sx, sy, ex, ey),
                d2_p_seg(xj, yj, sx, sy, ex, ey)].min
      break if min_d2 == 0.0
    end

    #p [incl, min_d2]
    if incl || min_d2 == 0.0
      min_r2 = 0.0
      break
    end

    r2 = 0.0
    h2 = hi ** 2

    if min_d2 <= h2
      r2 = min_d2
    else
      r2 = ((min_d2 + h2) / (2 * hi)) ** 2
    end

    min_r2 = r2 if min_r2 > r2
    #p [r2, min_r2]
  end

  puts Math.sqrt(min_r2)
end