F. Dragon Ball
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Ashley Ketchup is training to be the best dragon collector in the world, and she needs your help.

Whenever she collects a dragon, she keeps them in a small, spherical habitat, known as a "Dragon Ball". Ashley has many of these dragon balls, but she wants to make sure that the dragons she puts in there are always happy. Dragons come in all shapes and sizes, and can be easily intimidated by other dragons. Ashley wants to keep track of the dragons as she adds more to her collection and make sure they are always doing ok. Can you help Ashley?

Input

The first line contains a single integer, $$$t$$$ ($$$1 \leq t \leq 100$$$), representing the number of actions that Ashley performs.

Then, $$$n$$$ lines follow, which will be in one of the following forms:

  • $$$\text{add [habitat_name] [dragon_name] [dragon_size]}$$$: Ashley adds a dragon to the specified habitat. Initially, all habitats are empty.
  • $$$\text{ask [habitat_name]}$$$: Ashley wants to know the smallest and largest dragon in the habitat. It is guaranteed that the specified habitat will have at least one dragon.
All names will only contain lowercase English letters. All dragons have distinct names and sizes, which are positive integers at most $$$100$$$.
Output

Each time Ashley asks about a habitat, output the name of the smallest dragon, and the name of the largest dragon, in that order.

Example
Input
9
add garden saladmander 5
add garden leekachu 6
add mountain coldasaur 8
ask garden
ask mountain
add garden myrtle 2
add lake fishy 3
ask garden
ask lake
Output
saladmander leekachu
coldasaur coldasaur
myrtle leekachu
fishy fishy