An orbital transfer station keeps its freight ledger in a terse numeric form: every sale references a cargo module by a short code rather than its full name, which suits the station's own computers but is useless to the customs officers who read the printed manifest. The station also keeps a module directory that maps each code to the module's full name. You must expand the ledger into a readable manifest: for every sale entry, replace its module code with the module's name and drop the shipped-unit count entirely (customs only cares about the year and the price actually charged per unit), while keeping every entry in the exact order it appears in the ledger.
Line 1: two integers M and S — the number of entries in the module directory and the number of sale entries in the ledger.
The next M lines each contain a module code and the module's name: moduleCode moduleName.
The next S lines each describe one sale: saleId moduleCode year quantity price.
Print exactly S lines. For the i-th sale entry in the ledger (in input order), print moduleName year price, where moduleName is the name of the module referenced by that entry's moduleCode.
Example 1
Input
2 4 100 Nova 200 Zephyr 1 100 2008 10 5000 2 100 2009 12 5000 7 200 2011 15 9000 3 200 2009 30 9000
Expected
Nova 2008 5000 Nova 2009 5000 Zephyr 2011 9000 Zephyr 2009 9000
Explanation
The module directory maps code 100 to Nova and code 200 to Zephyr. The four ledger entries reference codes 100, 100, 200, 200 in that order, so the expanded manifest replaces each code with its module name and keeps that entry's year and price (dropping the quantity), producing 'Nova 2008 5000', 'Nova 2009 5000', 'Zephyr 2011 9000', and 'Zephyr 2009 9000' in the original ledger order.
Example 2
Input
1 1 50 Comet 9 50 2020 3 100
Expected
Comet 2020 100
Explanation
There is one module, code 50 named Comet, and one sale of it in 2020 at a price of 100 per unit (quantity 3 is not printed), so the manifest has the single line 'Comet 2020 100'.
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 →