Physics
In a three-dimensional space using a rectangular Cartesian coordinate system, there are n perfectly elastic spheres. For each sphere, the following information is provided: mass m_i, radius r_i, coordinates x_i, y_i, z_i, and velocity vector v_i = (v_ix, v_iy, v_iz) at the initial time. Your task is to determine their coordinates and velocities after T seconds from the initial moment. The spheres only interact through collisions; no other interactions occur between them.
Keep in mind that the spheres may collide, and such collisions are governed by the conservation of energy and momentum. This means that the quantity m_i·(v^2_ix + v^2_iy + v^2_iz) is conserved, as well as the vector m_i·v_i. Note that upon collision, the velocities of the spheres can only change in a direction parallel to the line connecting their centers at the moment of impact.
Input
The first line of the input file contains a natural number n (1 ≤ n ≤ 50) — the number of spheres. The next n lines describe the initial state of the spheres, with the (i+1)-th line containing 8 real numbers separated by spaces, each with up to three decimal places: m_i, r_i, x_i, y_i, z_i, v_ix, v_iy, v_iz.
The last line of the input file contains an integer T (0 ≤ T ≤ 100) — the time after which the system's state needs to be calculated. All velocity components are given in meters per second, all radii and center coordinates are in meters, all masses are in kilograms, and time T is in seconds. It is guaranteed that each collision involves exactly 2 spheres. All numbers in the input file do not exceed 100 in absolute value. Initially, the spheres do not touch or intersect each other. The masses and radii of all spheres are strictly positive.
Output
Output n lines in the output file. On the i-th line, output 6 real numbers with a precision of at least 3 decimal places: the x-coordinate of the center of the i-th sphere, the y-coordinate of the center of the i-th sphere, the z-coordinate of the center of the i-th sphere, the projection of its velocity on the Ox axis, the projection of its velocity on the Oy axis, and the projection of its velocity on the Oz axis after T seconds. Output coordinates in meters and velocity projections in meters per second.