Space Expedition
In 2004, the inhabitants of the planet Cremonid embarked on a space expedition to a nearby galaxy, where they believed a habitable planet existed. They built a residential complex on their spaceship to house many scientists.
The residential complex is a rectangular parallelepiped with dimensions n×m×k. It is divided into cubic compartments, each measuring 1×1×1, resulting in a total of nmk compartments. Each compartment is identified by coordinates (x, y, z), where 1 ≤ x ≤ n, 1 ≤ y ≤ m, and 1 ≤ z ≤ k.
The distance between two compartments with coordinates (x_1, y_1, z_1) and (x_2, y_2, z_2) is defined as:
|x_1-x_2|+|y_1-y_2|+|z_1-z_2|.
Two compartments are considered to be in the same row if they differ by exactly one coordinate component (for example, (2, 4, 3) and (2, 6, 3) are in the same row). Compartments are adjacent if the distance between them is one.
Each compartment is equipped with a personal computer. After launch, the residents decided to network these computers. The network plan involves the following process: select two compartments in the same row. The first compartment is the starting point, and the second is the endpoint. A robot tasked with laying the network begins at the starting compartment. At each step, the robot moves to an adjacent compartment that minimizes the distance to the endpoint. It connects computers in adjacent compartments along its path, unless doing so would create a cycle. If a cycle would be formed, the robot notes the coordinates of this pair of adjacent compartments and skips the connection. The robot continues until it reaches the endpoint.
This process is repeated q times.
Your task is to identify which pairs of compartments the robot noted.
Input
The first line of the input contains four numbers: n, m, k, q (2 ≤ n, m, k ≤ 100, 1 ≤ q ≤ 20000).
The following q lines describe the pairs of compartments between which the robot moves. Each line contains six numbers: the first three are the coordinates of the starting compartment, and the next three are the coordinates of the ending compartment.
Output
For each pair of compartments that the robot noted, output a line with six numbers representing the coordinates of the compartments in the order they were traversed by the robot.