eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач

GLONASS

Лимит времени 1 секунда
Лимит использования памяти 64 MiB

Nowadays there are two global positioning systems in the world, that allow us to determine exact position and some other parameters of object that located on the ground. These are GPS (Global Positioning System) and GLONASS (Global Satellite Navigation System). Also there is the “Beidou” (北斗導航系統) system, that is being developed today.

These systems are based on the main principle – the position is determined by measurements of the distance to the object from the satellites, which coordinates are known. Distances are calculated using the time delay between the moment, when signal was sent from satellite and the moment, when signal was received by GPS or GLONASS receiver. To determine three-dimensional coordinates of the object one should know the distance from the object to at least three satellites. Moreover satellites should be in direct "visibility" of the object, and placed "around" the object.

The latter concept is specified by experts as follows: object must be strictly inside the tetrahedron, the three vertices of which coincide with the three given satellite, and the fourth is at the center of the Earth.

Since the satellites are constantly changing their position because of the orbital motion, and the object could be located in any geographical point, the total number of satellites in the system must be large enough so that one always be able to find three that meet specified conditions.

Software and hardware of global positioning systems is rather complex. Fortunately, you have to implement only a small part of it.

Assume that the sea level is at the distance of 6000 km from the center of the Earth. It is guaranteed that the object is strictly inside the tetrahedron with vertices at the center of the earth and satellites.

Write a program calculating the height of the object above sea level, given the coordinates of three satellites and their distances from the object.

Входные данные

Each of the first three lines consists of three numbers – the Cartesian coordinates of the first, second and third satellites, respectively. Center of the Earth is at the point (0, 0, 0).

There are three numbers separated by spaces in the fourth line – distances from the object to the first, second and third satellite, respectively.

All coordinates and distances are integers, given in meters, and can range from –10^8 to +10^8.

Выходные данные

The output file consists of one number with an accuracy of 0.5 meters.

Пример

Входные данные #1
6000031  40  0
6000031  0  40
6000031  -24  -32
50  50  50
Выходные данные #1
1.0