spaceship (ship)

The cows are in a badly damaged spaceship in planar outer space at
the point (X, Y) where both X and Y are in the range (-10,000..10,000).
They need to send a call for help to Earth, which is located at (0, 0).

Unfortunately, N (0 <= N <= 30) variously-sized rectangular asteroids
also inhabit outer space. Neither the spaceship nor the signal can
penetrate an asteroid, so the cows must fly their spaceship to a
place where they have a direct line-of-sight to Earth. The spaceship
and the signal are very small and can graze the edge of an asteroid,
and even fit between two asteroids that share an edge.

All the asteroids have sides parallel to the X and Y axes. No two
asteroids intersect, and neither the spaceship nor Earth is located
inside an asteroid.

Find the shortest distance the cows can fly to reach a point where
they can cowmunicate with Earth.

PROBLEM NAME: ship

INPUT FORMAT:

* Line 1: Three space-separated integers: N, X, and Y

* Lines 2..N+1: Each line describes an asteroid using four
        space-separated integers, respectively x_1, y_1, x_2 and y_2.
        The asteroid is a rectangle with corners at (x_1, y_1) and
        (x_2, y_2), where x_1 < x_2 and y_1 < y_2.

SAMPLE INPUT:

3 7 1
2 -5 4 1
5 0 6 5
6 4 10 6

OUTPUT FORMAT:

* Line 1: The minimum distance the cows must travel. Print the answer
        to three decimal places.

SAMPLE OUTPUT:

4.650

OUTPUT DETAILS:

The image below shows the asteroids. The green line shows the route
traveled by the cows and the blue line shows the path of the radio
transmission.