eolymp
bolt
Try our new interface for solving problems
Problems

Lasers

Lasers

Never before the special agent Ivan Okhotnichii had been so close to a failure. It had seemed that to get into a secret laboratory through a ventilation hole in the ceiling and hack the computer would be no trouble. However, from above Ivan noticed that the laboratory was pierced by \textbf{N} laser beams. Touching any of them would activate the alarm system. The \textbf{i}^th beam was generated by an emitter located at the point (\textbf{X_i}, \textbf{Y_i}, \textbf{Z_i}) and was directed along the vector (\textbf{u_i}, \textbf{v_i}, \textbf{w_i}). Ivan examined the room and determined the numbers \textbf{X_i} and \textbf{Y_i}. He also computed the vectors (\textbf{u_i},\textbf{v_i}, \textbf{w_i}). However, in order to plan his further actions, Ivan had to know the \textbf{Z} coordinates of the emitters as well. Luckily, for some pairs of laser beams Ivan managed to determine that the first beam in the pair was above the second (that meant that there existed \textbf{X}, \textbf{Y}, \textbf{Z_1}, \textbf{Z_2} such that the point (\textbf{X}, \textbf{Y}, \textbf{Z_1}) belonged to the first beam, the point (\textbf{X}, \textbf{Y}, \textbf{Z_2}) belonged to the second beam, and \textbf{Z_1} was greater than \textbf{Z_2}). Help Ivan to find one of the possible arrangements of the lasers in space. \InputFile The first line contains the number of lasers \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{100}). In each of the following \textbf{N} lines, there are the integers \textbf{X_i}, \textbf{Y_i}, \textbf{u_i}, \textbf{v_i}, \textbf{w_i}, which describe the \textbf{i}^th laser; these numbers are in the range from \textbf{−100} to \textbf{100}. In the next line, there is the number \textbf{M} of pairs of lasers for which their relative positions are known (\textbf{0} ≤ \textbf{M} ≤ \textbf{10000}). Each of the following \textbf{M} lines contains two different integers \textbf{i} and \textbf{j}, which mean that the \textbf{i}^th laser is above the \textbf{j}^th laser (\textbf{1} ≤ \textbf{i}, \textbf{j} ≤ \textbf{N}). None of the laser beams is parallel to the \textbf{OZ} axis, and no two beams lie in the same vertical plane. \OutputFile Output \textbf{N} real numbers, one number per line, which are the coordinates \textbf{Z_i}. Their absolute values shouldn't exceed \textbf{10^6}. The numbers must be given with the maximal possible accuracy. The existence of at least one arrangement of lasers complying with the input data is guaranteed.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
0 0 1 0 0
1 0 0 1 0
1 1 -1 0 0
0 1 0 -1 0
3
1 2
2 3
3 4
Output example #1
0.0000000000
-0.0000010000
-0.0000020000
-0.0000030000
Author Dmitry Ivankov, Alex Samsonov
Source XIII Open USU Championship