eolymp
bolt
Try our new interface for solving problems
Problems

Heroes 2

Heroes 2

Not long ago the game "Heroes of Keyboard and Mouse 2" was released. The 4D-Action essence be the following: A number of cities are placed in a four-dimensional space. Every city is located in a certain point. The player can build new cities. And rob "corovans". At all times all cities are surrounded by a single connected wall of a finite size. The wall splits the game space into two parts: everything that’s within it and all that’s outside. The wall is built so that: \begin{enumerate} \item All the cities are within the wall. \item There is a straight path between any two points within the wall, not crossing the wall. \item The set of points within the wall is minimal as long as the conditions \textbf{1} and \textbf{2} are met. \end{enumerate} When a new city is built, the wall has to be rebuilt if the city lies outside it. Your task is to define whether wall reconfiguration is necessary for every newly built town. It is guaranteed that a new city is always built either outside of the existing wall or within it. Moreover, the distance from the new city to the wall is always greater than \textbf{10^\{--3\}}. No two cities occupy the same point. \InputFile The game begins with five cities with the coordinates (\textbf{x_1}, \textbf{y_1}, \textbf{z_1}, \textbf{w_1}), (\textbf{x_2}, \textbf{y_2}, \textbf{z_2}, \textbf{w_2}), …, (\textbf{x_5}, \textbf{y_5}, \textbf{z_5}, \textbf{w_5}), which are defined in the first five lines of the input file. The initial 4D volume within the wall is strictly positive. The second line contains an integer \textbf{N} --- the number of newly built cities (\textbf{1} ≤ \textbf{N} ≤ \textbf{800}). Each of the following \textbf{N} lines contains four integers --- the coordinates of a newly built city. The absolute value of each coordinate does not exceed \textbf{5000}. \OutputFile The output file must contain \textbf{N} lines. The \textbf{K}-th line must contain the word \textbf{Rebuild}, if wall reconfiguration is necessary after building \textbf{K}-th town, and the word \textbf{Ignore} otherwise (\textbf{1} ≤ \textbf{K} ≤ \textbf{N}). \textbf{Comments} Initially five cities are placed at the vertices of a coordinate simplex with the length \textbf{8} along the axes. The wall is exactly the boundary of the simplex. The equation of the large hyperplane of the simplex is the following: \textbf{x + y + z + w = 8}. As it can be seen from the equation, the first newly built city belongs to the simplex and doesn’t require wall reconfiguration, and the second city lies outside the simplex and the wall must be rebuilt. Once the wall has been rebuilt, the set of interior points consists of two adjacent simplexes. When the third city is built, the wall is reconfigured, and after that the set of interior points also consists of two simplexes. The fourth city belongs to this set, and the fifth apparently lies outside of it.
Time limit 1 second
Memory limit 64 MiB
Input example #1
0 0 0 0
8 0 0 0
0 8 0 0
0 0 8 0
0 0 0 8
5
1 2 2 2
2 2 3 2
8 8 8 8
3 5 3 4
-1 3 7 2
Output example #1
Ignore
Rebuild
Rebuild
Ignore
Rebuild
Source XIII All-Siberian Programming Contest named after I.V.Pottosin, November 11, 2012