Naval battle
시간 제한3초메모리 제한1024 MB
짝수 좌표에서 네 방향으로 움직이는 배들이 충돌로 사라지는 과정을 시뮬레이션하고, 살아남은 배의 번호를 출력한다.
문제
Ondra has recently been promoted to Grand admiral of the Czech Navy. However, when he finally started thinking he had a secure job, the government announced budget cuts including dissolution of the Navy.
So Ondra decided to show the government how important the Czech Navy is. He knows from his spies about an upcoming naval battle of four great fleets. If he could win it, it would surely make enough of a demonstration.
Unfortunately, the Czech Navy has neither warships nor sea ports. But if Ondra's spies took over some ships he might have a chance. If only he knew which ships will survive the battle…
A naval battle goes as follows: Initially ship starts on square , where both and are even. Additionally, the ship belongs to one of the four fleets: Northern, Southern, Eastern or Western. Then the battle proceeds in steps. In each step:
- First, each ship simultaneously moves one square in the direction corresponding to its fleet.
- If two or more ships now occupy the same square, they sink and disappear from the map.
The battle ends when no crashes are possible anymore. A surviving ship is a ship that remains on the map after the end of the battle.
A ship moves according to the direction of its fleet. The movement in each direction changes its coordinates as follows:
- Northern — decreases the coordinate by 1
- Southern — increases the coordinate by 1
- Eastern — increases the coordinate by 1
- Western — decreases the coordinate by 1
입력
The first line of inputs contains an integer . Then lines follow, each containing , , and , separated by spaces. The integers and are the coordinates of the -th ship. The character is either N, S, E or W, describing the direction of the -th ship's fleet.
No two ships initially have the same coordinates. That is, for ships and () either or .
출력
For each surviving ship, output a single line containing the integer () — the number of the ship. You can output the numbers of surviving ships in any order.
If there are no surviving ships, the output should be empty.
제한
- (for each such that ) and are even.