시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB66171531.250%

문제

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 $i$ starts on square $(x_i, y_i)$, where both $x_i$ and $y_i$ 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 $y$ coordinate by 1
  • Southern — increases the $y$ coordinate by 1
  • Eastern — increases the $x$ coordinate by 1
  • Western — decreases the $x$ coordinate by 1

입력

The first line of inputs contains an integer $N$. Then $N$ lines follow, each containing $x_i$, $y_i$, and $d_i$, separated by spaces. The integers $x_i$ and $y_i$ are the coordinates of the $i$-th ship. The character $d_i$ is either N, S, E or W, describing the direction of the $i$-th ship's fleet.

No two ships initially have the same coordinates. That is, for ships $i$ and $j$ ($i \neq j$) either $x_i \neq x_j$ or $y_i \neq y_j$.

출력

For each surviving ship, output a single line containing the integer $i$ ($1 \leq i \leq N$) — 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.

제한

  • $2 \leq N \leq 2 \cdot 10^5$
  • $0 \leq x_i, y_i \leq 10^9$ (for each $i$ such that $1 \leq i \leq N$) and $x_i, y_i$ are even.

서브태스크

번호배점제한
16

$N = 2$

212

$N \leq 100$, $x_i, y_i \leq 100$ (for each $i$ such that $1 \leq i \leq N$)

38

$N \leq 100$, $x_i, y_i \leq 10^5$ (for each $i$ such that $1 \leq i \leq N$)

411

$N \leq 200$

59

$N \leq 5\,000$

630

$d_i$ is either S or E (for each $i$ such that $1 \leq i \leq N$)

724

no additional constraints

예제 입력 1

7
0 6 E
0 8 E
2 4 E
4 2 S
6 0 S
6 2 S
6 4 S

예제 출력 1

7

The battle will initially look like this:

And then it proceeds as follows:

  • During step 2, ships 3 and 4 will collide at $(4, 4)$.
  • During step 6, ships 1 and 5 will collide at $(6, 6)$. At the same time 2 and 6 will collide at $(6, 8)$. The only surviving ship will be number 7.

예제 입력 2

5
4 0 S
0 2 E
2 2 E
4 4 N
6 6 W

예제 출력 2

5
2

During the second step, ships 1, 3 and 4 will collide at $(2, 4)$. Ships 2 and 5 will survive.

채점 및 기타 정보

  • 예제는 채점하지 않는다.