A field of size w \times h centimeters has one corner at and another one at . There are ants running along coordinate grid lines inside the field. Each ant can run in one of directions with speed centimeter per second.
Since ants are very proud creatures, they never give way. Thus, if several ants face head-on, they immediately turn around and run in the opposite direction. When two ants run perpendicular they will not pay attention to each other. If an ant reaches the boundary of the field, it also turns around and runs back. You are given positions and directions of movement of all the ants in initial moment of time. Find their positions and directions of movement after seconds.
The first line contains integers: , , , (1 \leq w, h, k \leq 100; 1 \leq t \leq 10^9).
Each of the following lines contains integers: x_i, y_i, d_i, where (x_i, y_i) - coordinates of the th ant; d_i - direction of its movement (0 < x_i < w; 0 < y_i < h; 1 \leq d_i \leq 4). d_i = 1 if ant moves in direction of increasing ; d_i = 2 - in direction of increasing ; d_i = 3 - in direction of decreasing ; d_i = 4 - in direction of decreasing .
All of the numbers in lines are separated by single spaces. All ants are located in different points.
Output consists of exactly lines - one line for each ant in the same order as they are given in the input. Each line contains integers separated by single spaces - coordinates of the ant and direction of its movement.
Example 1
Example 2
Example 3
Example 4