P2580 And Thus His Mistaken Roll Call Began

Background

The coach of the XS Middle School chemistry competition team is a big fan of Hearthstone. He plays Hearthstone while taking attendance, and one day he called the same student twice in a row. The principal happened to pass by, and then it was a round of "ora ora ora" (for details, see the ended contest CON900).

Description

After that, the principal appointed you as a special agent to record his roll calls every day. The principal will provide the number of chemistry competition students and the roster, and you need to tell the principal whether he called the names correctly. (Why not just stop him from playing Hearthstone.)

Input Format

The first line contains an integer $n$, the number of students in the class. The next $n$ lines each contain a string representing a name (all distinct, lowercase letters only, length no more than $50$). The $(n+2)$-th line contains an integer $m$, the number of names the coach called. The next $m$ lines each contain a string representing a name called by the coach (lowercase letters only, length no more than $50$).

Output Format

For each name called by the coach, output one line. If the name is correct and appears for the first time, output `OK`. If the name is incorrect, output `WRONG`. If the name is correct but not the first time, output `REPEAT`.

Explanation/Hint

- For $40\%$ of the testdata, $n \le 1000$, $m \le 2000$. - For $70\%$ of the testdata, $n \le 10^4$, $m \le 2 \times 10^4$. - For $100\%$ of the testdata, $n \le 10^4$, $m \le 10^5$. --- $\text{upd 2022.7.30}$: A new set of Hack testdata was added. Translated by ChatGPT 5