About
CCC '08 J2 - Do the Shuffle
songs = ["A", "B", "C", "D", "E"]
while True: n = int(input()) if n == 4: break t = int(input())
for i in range(t):
if n == 1:
# Move first song to the end
songs.append(songs.pop(0))
elif n == 2:
# Move last song to the front
songs.insert(0, songs.pop())
elif n == 3:
# Swap first and second songs
songs[0], songs[1] = songs[1], songs[0]
print(" ".join(songs))