Katya listens to music. There are already several songs in the player's queue. The title and length of each song are known.
The player plays the song that is first in the queue and immediately removes it from there. Sometimes Katya comes across a new track that she wants to listen to next, at which point she presses the "Play Next" button. This song becomes the first in the player's queue, but the current song continues to play until the end. If this happens when the current song has finished, the next song to play will be the new track.
Your task is to determine the order in which Katya will listen to the songs and when each of them will start.
The first line contains an integer $$$n$$$ — the number of songs in the player at the moment when Katya started listening to music ($$$1 \le n \le 100\,000$$$).
The next $$$n$$$ lines each contain two values: $$$name_i$$$, $$$len_i$$$, where $$$name_i$$$ — the title of the song, and $$$len_i$$$ — the length of the song in seconds ($$$1 \le len_i \le 10^9$$$).
The following line contains an integer $$$m$$$ — the number of events adding songs to the front of the queue ($$$0 \le m \le 100\,000$$$).
The next $$$m$$$ lines each contain three values: $$$t_j$$$, $$$name_j$$$, $$$len_j$$$, where $$$t_j$$$ — the moment in time the song is added in seconds ($$$0 \le t_j \le 10^9$$$), $$$name_j$$$ — the name of the added song, and $$$len_j$$$ — its length in seconds ($$$1 \le len_j \le 10^9$$$).
It is guaranteed that the times of addition are given in non-decreasing order. The titles of the songs consist only of Latin letters, and their length does not exceed 20.
For each played song, output one line containing two values: $$$name_k$$$ and $$$start_k$$$, where $$$name_k$$$ — the name of the song, and $$$start_k$$$ — the moment in time when this song started playing. The songs should be listed in the order in which Katya listened to them.
3Abracadabra 223Pedro 145Believer 2203223 Abracadabra 223223 STAY 1201024 Friday 1234
Abracadabra 0 STAY 223 Abracadabra 343 Pedro 566 Believer 711 Friday 1024