Under construction

Still being built. Things may change

Save the Earth

Time limit2sMemory limit1024 MB

Summary
Find the shortest walk from a house to a point within r1 of antenna 1 and within r2 of antenna 2, given the antennas are farther apart than r1 + r2.
Level

Medium6 of 10

Topics
Geometry, Math, Binary search
Solved
No attempts yet

Statement

Aliens have invaded Earth. The situation is not as hopeless as it first looks. Rick can hack the alien ships and make them turn around and leave the solar system. To do this, he must connect to the two largest parabolic antennas in the area. Morty has nearly convinced Rick, but Rick keeps resisting because he is lazy.

To keep Morty off his back for a couple of minutes, after which Rick will still have to go save the world, Rick asked Morty to find the length of the shortest path Rick must travel from the house where he is now to turn on both antennas. To turn on the first antenna, Rick must be within distance r1r_1 of it, and to turn on the second, within distance r2r_2.

As you may have guessed, neither antenna can be turned on from the house. Also, due to technical limitations, the distance between the antennas is strictly greater than r1+r2r_1 + r_2.

Assume there are no obstacles on the plane. Rick may even walk through the place where an antenna stands.

Input

The first line contains three integers x1x_1, y1y_1, and r1r_1, the coordinates of the first antenna on the plane and its radius parameter (−106≤x1,y1≤106-10^6 \le x_1, y_1 \le 10^6, 1≤r1≤1061 \le r_1 \le 10^6). The second line contains three integers x2x_2, y2y_2, and r2r_2, the coordinates of the second antenna (−106≤x2,y2≤106-10^6 \le x_2, y_2 \le 10^6, 1≤r2≤1061 \le r_2 \le 10^6). The third line contains two integers xx and yy, the coordinates of the house where Rick is now (−106≤x,y≤106-10^6 \le x, y \le 10^6).

Output

Print one line with the length of the shortest path Rick must travel to turn on both antennas. The answer is accepted with an absolute or relative error of at most 10−610^{-6}.

Hint

Figure 1: Explanation for the first test

Figure 2: Explanation for the second test

Examples2

  1. Example 1

    Input
    2 1 1
    3 4 1
    0 0
    
    Expected output
    4.0000000000
    
  2. Example 2

    Input
    0 0 2
    4 -2 1
    -2 -4
    
    Expected output
    5.7382161910