#P9855. CCC Music Player Simulation

    ID: 23000 Type: Default 1000ms 256MiB

CCC Music Player Simulation

CCC Music Player Simulation

The CCC Music Player ($C^3MP$) is a small music machine that stores and plays your digital music files. It maintains a playlist of 5 fixed songs titled A, B, C, D and E. Initially, the playlist is in the order A,B,C,D,E.

The player provides 4 control buttons that modify the playlist:

  • Button 1: Move the first song of the playlist to the end. For example, $$A,B,C,D,E \to B,C,D,E,A$$.
  • Button 2: Move the last song of the playlist to the start. For example, $$A,B,C,D,E \to E,A,B,C,D$$.
  • Button 3: Swap the first two songs of the playlist. For example, $$A,B,C,D,E \to B,A,C,D,E$$.
  • Button 4: Stop rearranging and output the current playlist.

Your task is to simulate the $C^3MP$ by processing a sequence of button presses (as numbers). When a button press of 4 is encountered, the simulation stops and the current playlist is output as a comma-separated list.

inputFormat

A single line containing a series of integers separated by spaces. Each integer is between 1 and 4, representing a button press. It is guaranteed that the sequence will contain at least one button 4 to stop the simulation.

outputFormat

Output the final playlist as a comma-separated list of song titles. There should be no extra spaces.

sample

1 3 4
B,A,C,D,E