Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

2175.   Computer Games
Time Limit: 2.0 Seconds   Memory Limit: 65536K
Total Runs: 689   Accepted Runs: 104



Almost all the TJU ACMers are good at computer games. During the long and boring summer, they want to play some games to relax. But their levels are quite different, for example, wtommy can beat others easily in the game StarCraft. They want the game to be more attractive, so every time they choose two members, whose levels are nearest, to fight. For there are so many people join and leave the team, this task turned to be very difficult. Now they are asking you for help.

Input

The first line of each test case contain a number M (1 ≤ M ≤ 105) indicating the number of commands.

Each of The following M lines is one command. There are three types of commands:

  • Join SS P : A new member called SS has joined the TJU ACM team. His game level is P. (0 < P < 108)
  • Leave SS : The member SS has left the team.
  • Play : oh yeah , they want to choose two guys to fight.

You can assume all the names is made up of less than 20 letters. All the people have different levels and different names. All the people will join and leave the team at most once.

The input is terminated by a test case starting with M = 0. This test case should not be processed.

Output

Your program should respond to each 'Play' command , output one line containing the two names chosen to fight or "Poor Mr.Yu" if there are less than two members in the team. Please note the one with the higher level will come first. If there are more than one pair whose levels are nearest, you should output the pair with highest level, because people think the fight between higher levels will be more attractive.

You should print a blank line after each test case.

Sample Input

8
Join WTommy 80
Join RoBa 50
Play
Join Washington 65
Play
Leave WTommy
Leave RoBa
Play
0

Sample Output

WTommy RoBa
WTommy Washington
Poor Mr.Yu

Hint: Huge input and output, scanf() and printf() is recommend.


Author: Robby



Source: TOJ 1st Anniversary Contest
Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.3.0
Maintance:Fxz. Developer: SuperHacker, G.D.Retop, Fxz