| UTPC Spring 2024 Open Contest |
|---|
| Finished |
Noah loves music and has various albums stored on discs. However, whenever he listens to his albums, he is very picky about the songs and skips around a lot. The disc always starts on the first song and rotates in order of the album. Once it gets past the end, it restarts from the beginning. Given how many songs Noah skips before listening to each song, print the list of songs in the order he listened to them.
Note: Whenever he decides on a song, he listens to it in its entirety before counting his skips to the next song.
The first line will contain two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 10^5$$$) — the number of songs in the album and number of songs he listened to.
The next $$$n$$$ lines each contain the name of a song in the order of the album. Each name is guaranteed to be no more than 100 characters.
The last $$$m$$$ lines each contain a single integer $$$s_i$$$ ($$$1 \leq s_i \leq 10^9$$$) — the number of songs Noah skipped before listening to the $$$i$$$th song.
The output should contain $$$m$$$ lines each containing the name of a single song in the order Noah listened to them.
12 7Maybe ManTouchy Feely FoolYes I'm A MessThe Dumb SongInertiaTurning Out Pt. iiiHole in the Bottom of My BrainThe DJ is Crying for HelpI Won'tSteve's Going to LondonGod is Really Real208535246131
The Dumb Song Steve's Going to London Maybe Man Turning Out Pt. iii Maybe Man Yes I'm A Mess Inertia
| Name |
|---|


