Those tiny music machines that play digital music are really small computers that store and play music files. A new portable music player called the C3MP is in development and will hit stores soon. In this problem you have to simulate a C3MP.
The C3MP holds 5 songs in memory, whose titles are always “A”, “B”, “C”, “D” and “E”. It also keeps a playlist, which is an ordering of all the songs. The player has 4 buttons that rearrange the playlist and play the songs.
Initially the playlist is A, B, C, D, E. The 4 buttons do the following:
The input is a sequence of button presses. Each press is given as two positive integers $b$ and $n$: $b$ is the button number ($1 \le b \le 4$) and $n$ is the number of times to press button $b$ ($1 \le n \le 10$). The two integers of a press may be separated by spaces or newlines.
The input always ends with the press $b = 4$, $n = 1$. When you read it, print the current playlist and stop. Button 4 is pressed exactly once, at the very end.
Print the titles of the songs in the final playlist order, on one line, separated by single spaces.