URI Online Judge | 2022

Christmas Gifts

By Jessica Dagostini, URI Online Judge BR Brazil

Timelimit: 1

Oh the Christmas time... magic time, time of good senses, dinners full of cool people and filled with good food and, of course: many gifts!

Jucilena was a good girl in this year. Knowing it, she is making a list with her christmas wishes. However, Jucilena is an undecided girl (and her wishes are many), what makes Nicolau confused from what present she really wants. On their lists, cast the name of the desired gift, its value (this field prompted by her mother) and the preference of the same in a scale, from the least preferred (1) to the most desired (10). Seeing this idea, Jucilena's friends also do the same, because all have various gift options.

All this messing lists and gifts left, Santa Claus is crazy! Seeing this, the Christmas spirit has touched you and you decided to help Santa, creating a program that shows the list of the most desired gifts for Jucilena and his friends. Gifts should be shown in descending order of preference. If the preference of one another is the same, it should be shown the lowest value first. If there is similarity between preference and value, they should be listed in alphabetical order.

Input

The input consist in many test cases. The first line of each test case contains the Name (without spaces) of respective owner of the list, together with a integer Q (1 < Q <100) whats define a quantity of gifts listed. The next Q*2 lines consist in a name O of the desired object in a line and the P (1< P < 100.000.000) cost of the same the prefer's value E (1< E < 10)‚Äč in the next line.

Output

The ordered list should be printed within the guidelines outlined above, being first shows the name of the owner of preceded by "Lista de ", followed by a list that only shows the object name followed by its value in Brazilian real, with two digits after the decimal point. Should be printed a blank line after all outputs.

Input Samples Output Samples

Jucilena 7
Xbox
1250.50 7
Notebook
2200.00 9
Quadro magnetico
150.00 5
Xadrez
50.00 7
Smartphone
950.00 10
Livro Star Wars
35.00 6
Porta retratos
15.00 2

Anelise 10
Televisao
700.00 7
Colecao Harry Potter
180.00 8
Bolsas
150.00 8
Camera fotografica
1200.75 10
Playstation 3
1200.75 10
Viagem Disney
5000.56 10
Cachorrinho
300.30 5
Assinatura 1 ano Netflix
240.00 9
Cd The Script
35.00 8
Blusas
50.00 2

Lista de Jucilena
Smartphone - R$950.00
Notebook - R$2200.00
Xadrez - R$50.00
Xbox - R$1250.50
Livro Star Wars - R$35.00
Quadro magnetico - R$150.00
Porta retratos - R$15.00

Lista de Anelise
Camera fotografica - R$1200.75
Playstation 3 - R$1200.75
Viagem Disney - R$5000.56
Assinatura 1 ano Netflix - R$240.00
Cd The Script - R$35.00
Bolsas - R$150.00
Colecao Harry Potter - R$180.00
Televisao - R$700.00
Cachorrinho - R$300.30
Blusas - R$50.00