GameZ has launched a website for their latest game. Players from all over the world can upload their game scores to the website to see their global ranking. A higher score results in a higher rank. If two players have the same score, the one who uploaded their record first is ranked higher. Due to the popularity of the new game, the website's server is struggling under the load. GameZ has hired you to help them redevelop the core system.
The ranking system typically handles three types of requests: uploading a new score record, querying the current rank of a specific player, and returning the ranking records within a certain range. When a player uploads their latest score record, their previous score record is deleted. To reduce the server load, when returning ranking records within a range, at most 10 records are returned.
Input
The first line of the input contains an integer $n$ ($n \ge 10$), representing the total number of requests. The next $n$ lines each contain a request. The specific format of the requests is as follows:
+Name Score: Upload the latest score record.Namerepresents the player's name, consisting of uppercase English letters, not exceeding 10 characters.Scoreis a positive integer of at most 8 digits.?Name: Query the rank of a player. The player's score record must have already been uploaded previously.?Index: Return the names of up to 10 players starting from theIndex-th rank.Indexis guaranteed to be valid, i.e., not less than 1 and not greater than the total number of players currently recorded.
The total size of the input file does not exceed 2MB.
NOTE: Using C++ fstream to read large-scale data is relatively inefficient.
Output
For each query request, output the corresponding result. For requests in the ?Name format, output an integer representing the player's current rank. For requests in the ?Index format, output the names of up to 10 players starting from the Index-th rank on a single line, separated by spaces.
Examples
Input 1
20 +ADAM 1000000 +BOB 1000000 +TOM 2000000 +CATHY 10000000 ?TOM ?1 +DAM 100000 +BOB 1200000 +ADAM 900000 +FRANK 12340000 +LEO 9000000 +KAINE 9000000 +GRACE 8000000 +WALT 9000000 +SANDY 8000000 +MICK 9000000 +JACK 7320000 ?2 ?5 ?KAINE
Output 1
2 CATHY TOM ADAM BOB CATHY LEO KAINE WALT MICK GRACE SANDY JACK TOM BOB WALT MICK GRACE SANDY JACK TOM BOB ADAM DAM 4