{"problem":{"name":"Swiss-System Tournament","description":{"content":"$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 ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc222_c"},"statements":[{"statement_type":"Markdown","content":"$2N$ players, with ID numbers $1$ through $2N$, will participate in a rock-scissors-paper contest.\nThe contest has $M$ rounds. Each round has $N$ one-on-one matches, where each player plays in one of them.\nFor each $i=0, 1, \\ldots, M$, the players' ranks at the end of the $i$\\-th round are determined as follows.\n\n*   A player with more wins in the first $i$ rounds ranks higher.\n*   Ties are broken by ID numbers: a player with a smaller ID number ranks higher.\n\nAdditionally, for each $i=1, \\ldots, M$, the matches in the $i$\\-th round are arranged as follows.\n\n*   For each $k=1, 2, \\ldots, N$, a match is played between the players who rank $(2k-1)$\\-th and $2k$\\-th at the end of the $(i-1)$\\-th round.\n\nIn each match, the two players play a hand just once, resulting in one player's win and the other's loss, or a draw.\nTakahashi, 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`.  \nHere, `G` stands for rock, `C` stands for scissors, and `P` stands for paper. _(These derive from Japanese.)_\nFind the players' ranks at the end of the $M$\\-th round.\nRules of rock-scissors-paper The result of a rock-scissors-paper match is determined as follows, based on the hands played by the two players.\n\n*   If one player plays rock (G) and the other plays scissors (C), the player playing rock (G) wins.\n*   If one player plays scissors (C) and the other plays paper (P), the player playing scissors (C) wins.\n*   If one player plays paper (P) and the other plays rock (G), the player playing paper (P) wins.\n*   If the players play the same hand, the match is drawn.\n\n## Constraints\n\n*   $1 \\leq N \\leq 50$\n*   $1 \\leq M \\leq 100$\n*   $A_{i,j}$ is `G`, `C`, or `P`.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$\n$A_{1,1}A_{1,2}\\ldots A_{1,M}$\n$A_{2,1}A_{2,2}\\ldots A_{2,M}$\n$\\vdots$\n$A_{2N,1}A_{2N,2}\\ldots A_{2N,M}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc222_c","tags":[],"sample_group":[["2 3\nGCP\nPPP\nCCC\nPPC","3\n1\n2\n4\n\nIn 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.  \nIn 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.  \nIn 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.  \nTherefore, in the end, the players are ranked in the following order: $3,1,2,4$, from highest to lowest."],["2 2\nGC\nPG\nCG\nPP","1\n2\n3\n4\n\nIn 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.  \nIn 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.  \nTherefore, in the end, the players are ranked in the following order: $1,2,3,4$, from highest to lowest."]],"created_at":"2026-03-03 11:01:13"}}