Vangelis the Batbear trapped all the members of Joker’s Streetgang in a basement.
Your job as a police officer is to transport all gang members to Blackgate Penitentiary.
To facilitate the transport, you should form a row such that the heights of the gang members are in non-decreasing order. For each gang member you should find the min and the max position where they can be in a valid sorted row and produce a roster with this information.
Input will start with a line that contains only one integer
M, the number of crew members that were arrested. On each of the following
M lines there will be a single word
N and an integer
H separated by a space character, where
N is the name and
H is the height of the crew member.
On the output, there will be
G lines. Each line will contain in alphabetical order and space separated the names of the crew members that have the same height, followed by the min and the max position where any member of the specific group can be placed.
Limitations and notes
1 ≤ M ≤ 1000
1 ≤ length(N) ≤ 10
120 ≤ H ≤ 250
Names are only composed of characters of the Latin alphabet.
This post is also available in: Αγγλικα