A city museum keeps a numbered catalogue of exhibits, each identified by a unique exhibit id and given a display name. The museum's loan office separately keeps a chronological ledger of loan records; each record cites the id of the exhibit that was loaned out, the year of the loan, and the fee that was charged for it. For every loan record, in the order it was logged, report the display name of the exhibit that was loaned, together with that loan's year and fee.
The first line contains one integer p — the number of exhibits.
Each of the next p lines contains an integer exhibit_id and a string name (letters, digits, and underscores only, no spaces) describing one exhibit. Exhibit ids are distinct.
The next line contains one integer s — the number of loan records.
Each of the next s lines contains three integers exhibit_id, year, and fee describing one loan record. Every loan's exhibit_id matches the id of some exhibit given above.
For every loan record, in the order it appears in the input, print the exhibit's name, the loan's year, and the loan's fee, separated by single spaces, one loan per line.
Example 1
Input
2 1 MummyMask 2 DinoSkeleton 2 1 2020 100 2 2019 250
Expected
MummyMask 2020 100 DinoSkeleton 2019 250
Explanation
Exhibit 1 is named MummyMask and exhibit 2 is named DinoSkeleton. The first loan references exhibit 1 in year 2020 for a fee of 100, so it prints 'MummyMask 2020 100'. The second loan references exhibit 2 in year 2019 for a fee of 250, so it prints 'DinoSkeleton 2019 250'.
Example 2
Input
1 5 Telescope 3 5 2021 0 5 2021 0 5 2022 300
Expected
Telescope 2021 0 Telescope 2021 0 Telescope 2022 300
Explanation
There is only one exhibit, 'Telescope' (id 5). All three loans reference it, so every output line uses the name 'Telescope', each paired with that specific loan's own year and fee, printed in the same order the loans were given: two lines for the two identical 2021/fee-0 loans, then one line for the 2022/fee-300 loan.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →