410429: GYM104021 A Girls Band Party
Description
You are currently playing a game called "Garupa". In an event of the game, you are trying to get more event points. You have $$$n$$$ cards, each with its own name, color, and power. When you play the game, you can put five cards of different names into your deck. The base point of this event is the sum of the power of the cards in your deck. On top of that, the event publishes a color and five names as bonus attributes, which means that each time you have a card with a bonus color in the deck, you end up with a $$$20\%$$$ increase in event point. And each time you have a card with a bonus name in the deck, you will eventually get $$$10\%$$$ of the event point (bonus values are calculated by addition, and we round down when calculating the final event point). Please find the maximum event point you will eventually get.
InputThe first line is an integer $$$T~(1 \leq T \leq 50$$$), which is the number of test cases.
For each set of input data, input a positive integer $$$n~(5 \leq n \leq 100000)$$$ in the first line to indicate the number of cards you have.
The next $$$n$$$ lines, the $$$i$$$-th line input two strings $$$name_i$$$, $$$color_i$$$ and a positive integer $$$power_i~(1 \leq power_i \leq 50000)$$$ separated by spaces, indicating the name, color, and power of the $$$i$$$-th card. The input data ensures that there are at least five cards with different names.
The next line input five strings representing the five bonus names. The input data guarantees that the bonus names are different.
The last line input a string representing a bonus color.
The input data ensures that all strings consist of only uppercase and lowercase letters and the max length of them is $$$10$$$, and the sum of $$$n$$$ in all sets of input data does not exceed $$$1500000$$$.
OutputFor each set of data, output only one line of a positive integer, indicating the maximum number of bonus points that you will eventually get.
ExampleInput1 6 Saaya Power 45000 Kokoro Happy 45000 Kasumi Cool 45000 Rimi Power 45000 Aya Pure 45000 Aya Power 2000 Saaya Tae Kasumi Rimi Arisa PowerOutput
382500