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.
- Smaller judging time comes first.
- If the judging times are equal, earlier completion time comes first.
- If the completion times are also equal, the submission whose type- query appeared earlier comes first.
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.
- Larger solved count comes first.
- If the solved counts are equal, the user who achieved the current solved count earlier comes first.
- If those times are also equal, lexicographically smaller nickname comes first.
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.
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
Each query has one of the three formats described in the statement.
Output
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 -1 on one line.
For 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.
Constraints
- .
- .
- The sum of over all test cases does not exceed .
- The sum of over all test cases does not exceed .
- .
- Within each test case, query times are given in nondecreasing order.
- In a type- query, .
- In type- and type- queries, .
- In a type- query, .
- Nickname consists only of lowercase English letters and has length from to .
- Two different users never use the same nickname.
- Every number in the input is an integer.
Subtasks
Samples
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 carol, bob, alice because smaller judging time ranks higher.