#000146

BubbleSecurity

A space of size n x n x n is to be guarded by a complex security system, consisting of n sensors. Location of each sensor must have three integer coordinates between 1 and n, inclusive. Furthermore, each sensor should secure (and be located in) a particular part of the space, given by minimal and maximal values along axes. Finally, in order to be able to catch most of the movements, no two sensors can share any of the coordinates. For example, two sensors cannot have the same x coordinate, regardless of y and z coordinates. It is not always possible to meet all these conditions, but when it is, any arrangement of sensors will do the job. You are asked to help arrange the sensors.



InputFirst line contains the number n, with n ≤ 10000. In each of the next n lines, there
are six integers x1, y1, z1, x2, y2, z2, describing required subspace for kth sensor, 1 ≤ x1 ≤ x2 ≤ n, 1 ≤ y1 ≤ y2 ≤ n, 1 ≤ z2 ≤ z2 ≤ n, k=1, 2,… n.

Moderator notice: Apparently, some test cases also contain zeroes.


OutputIn each of n lines, there should be three integers separated by a space, coordinates of kth sensor,
k= 1,2,… n. If there is no solution, each of the n lines should contain three zeroes.

Input:
3
1 1 1 2 2 2
2 2 2 3 3 3
2 1 2 3 2 3


Output:
1 1 1
3 3 3
2 2 2

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.