Air Leak
문제
A space station is made up of cubic modules arranged in a grid. The position of each module in the grid is indicated by its X-, Y-, and Z-coordinates with integer values in the range . Any pair of modules next to each other along the X-, Y-, or Z-axis is connected by a tunnel. Each tunnel has doors at both ends. If both doors are open, air may flow between the two modules.
One of the modules has been damaged and leaks air into the space. Air is also being lost from all those modules from which it can flow to the damaged module, either directly or via other modules. Find all the modules that are losing air. You may assume that the doors of the damages module still work correctly.
입력
The first line contains , the number of open doors in the station (). Each of the following lines describes one open door: the coordinates of the module and the direction of the door (the name of the axis and '+' for the direction of increasing values of the coordinate, or '-' for the decreasing direction). The last line contains the coordinates of the damaged module.
출력
Output the coordinates of all the modules that are losing air, each module on a separate line. Order the lines in ascending order first by the Z-, then by the Y-, and finally by the X-coordinates.
예제
예제 1
5 2 1 1 X- 1 1 1 X+ 1 1 1 Z+ 3 1 1 X- 1 1 2 Z- 1 1 1
1 1 1 2 1 1 1 1 2