Score : $300$ points
$2N$ players, with ID numbers $1$ through $2N$, will participate in a rock-scissors-paper contest.
The contest has $M$ rounds. Each round has $N$ one-on-one matches, where each player plays in one of them.
For each $i=0, 1, \ldots, M$, the players' ranks at the end of the $i$-th round are determined as follows.
Additionally, for each $i=1, \ldots, M$, the matches in the $i$-th round are arranged as follows.
In each match, the two players play a hand just once, resulting in one player's win and the other's loss, or a draw.
Takahashi, who can foresee the future, knows that Player $i$ will play $A_{i, j}$ in their match in the $j$-th round, where $A_{i,j}$ is G
, C
, or P
.
Here, G
stands for rock, C
stands for scissors, and P
stands for paper. (These derive from Japanese.)
Find the players' ranks at the end of the $M$-th round.
G
, C
, or P
.Input is given from Standard Input in the following format:
$N$ $M$ $A_{1,1}A_{1,2}\ldots A_{1,M}$ $A_{2,1}A_{2,2}\ldots A_{2,M}$ $\vdots$ $A_{2N,1}A_{2N,2}\ldots A_{2N,M}$
Print $2N$ lines.
The $i$-th line should contain the ID number of the player who ranks $i$-th at the end of the $M$-th round.
2 3 GCP PPP CCC PPC
3 1 2 4
In the first round, matches are played between Players $1$ and $2$, and between Players $3$ and $4$. Player $2$ wins the former, and Player $3$ wins the latter.
In the second round, matches are played between Players $2$ and $3$, and between Players $1$ and $4$. Player $3$ wins the former, and Player $1$ wins the latter.
In the third round, matches are played between Players $3$ and $1$, and between Players $2$ and $4$. Player $3$ wins the former, and Player $4$ wins the latter.
Therefore, in the end, the players are ranked in the following order: $3,1,2,4$, from highest to lowest.
2 2 GC PG CG PP
1 2 3 4
In the first round, matches are played between Players $1$ and $2$, and between Players $3$ and $4$. Player $2$ wins the former, and Player $3$ wins the latter.
In the second round, matches are played between Players $2$ and $3$, and between Players $1$ and $4$. The former is drawn, and Player $1$ wins the latter.
Therefore, in the end, the players are ranked in the following order: $1,2,3,4$, from highest to lowest.