| AGM 2022, Final Round, Day 1 |
|---|
| Finished |
Although Gogu is considered to be the best search engine, we believe you can do something better. Let's do it!
There are 4 types of queries you can make to your custom search engine:
The first line of the input contains the integers $$$Q$$$ ($$$1 \leq Q \leq 500.000$$$) and $$$K$$$ ($$$1 \leq K \leq 10$$$), denoting the number of queries and the numbers of words the search engine will try to suggest. The next $$$Q$$$ lines have the following structure:
For each operation of the $$$1^{st}$$$ type print on one line the IDs of the most searched $$$K$$$ words (or less than $$$K$$$ if there are not that many) with the current typed prefix in descending order of their frequency. In case of equality in terms of frequency, the word with the smallest ID goes first. If there is no word with the given prefix print $$$-1$$$. The ID of a word is the index of the first query of type $$$4$$$ which searched it. Please note that the queries are 0-indexed.
19 3 1 a 1 a 4 3 1 a 4 3 1 a 4 3 1 b 4 3 1 c 4 2 1 a 2 1 b
-1 -1 2 2 -1 -1 2 11 14 -1
| Name |
|---|


