10205 - Stack 'em Up


Difficulty : easy

Solution Description :

Ad hoc Simulation Problem

Suppose you have 4 card - 1 2 3 4

If input
2 -> Total Shuffle No.
2 3 1 4 -> Shuffle No. 1 
4 2 1 3 -> Shuffle No. 2
1 -> Use Shuffle No. 1
2 -> Use Shuffle No. 2

At Initial the card sequence:
1 2 3 4 -> Now
2 3 1 4 -> Shuffle No.1
ans[1] = now[2] =2, ans[2]=now[3]=3, ans[3]=now[1]=1, and ans[4]=now[4]=4
copy the ans to now. So, the new now
2 3 1 4 -> Now
4 2 1 3 -> Shuffle No. 2
ans[1] = now[4] =4, ans[2]=now[2]=3, ans[3]=now[1]=2, and ans[4]=now[3]=1
copy the ans to now. So, the new now
4 3 2 1

Print the sequence.
Do this simulation which is describe above.
Remember the 52 cards sequence can be in one or more lines.