International OJ has judging servers numbered . Each server has one judging queue and can judge only one submission at a time. Every submission receives AC.
When a submission is inserted into a server's queue, that server judges submissions in FIFO order. If the server is idle, it starts judging the newly inserted submission immediately. While a submission is being judged, the server cannot judge another one. When a submission finishes, its result is reflected in the database at the same time. If another submission is waiting in the queue, the server starts that submission immediately at the same time.
International OJ provides two rankings.
For each problem, completed submissions are ordered by the following rules.
Even if one user submits the same problem multiple times, every submission is treated as a separate record.
A user's solved count is the number of distinct problems for which the user has at least one completed AC submission. Multiple submissions to the same problem increase the solved count only once. Users are ordered by the following rules.
The time at which a user achieved the current solved count is the completion time of the most recent submission that made the user solve a new problem for the first time. A user with no completed submission is not included in the user ranking.
Process queries in order. There are three query types.
At time , insert a submission for problem , with judging time and nickname , into server 's queue. If server is idle at time , it starts judging the submission immediately.
Using only submissions completed by time , print the ranking for problem . Print at most the highest-ranked submissions. For each submission, print its nickname and judging time. If no submission has completed, print -1.
Using the results reflected in the database by time , print the user ranking. Print at most the highest-ranked users. For each user, print the nickname and solved count. If no user belongs to the ranking, print -1.
The input is given from Standard Input in the following format:
For each test case, whenever a type- or type- query appears, print its result in query order.
For a type- query, if records exist, print at most the highest-ranked records, one per line, in the following format:
where is the nickname and is the judging time. If there is no record, print on one line.
bob's submission starts on server 2 at time and finishes at time . alice's submission to problem 1 finishes at time , and her submission to problem 2 also finishes at time , so she has solved two problems at that time. carol's submission starts at time and finishes at time . At time , the problem-1 ranking is , , because smaller judging time ranks higher.
Each case is given in the following format:
Each query has one of the three formats described in the statement.
-1For a type- query, if users exist, print at most the highest-ranked users, one per line, in the following format:
where is the nickname and is the solved count. If there is no user, print -1 on one line.
Do not print additional separators between outputs of different queries or test cases.
| 3 | 18 | There is no type- query. |
| 4 | 15 |
|
| 5 | 20 | Every pair is submitted at most once. |
| 6 | 25 | No additional constraints. |
carolbobalice