#Lutece3327. Shift the Permutation
Shift the Permutation
Description
There is a permutation of length , initially in ascending order from to , i.e. permutation . Now, consecutive shift operations will be performed on this permutation. There are two types of operations:
- : Move the last number in the permutation to the front.
- : Move the third number in the permutation to the front.
The consecutive operations are represented in the form of or , where is the number of times the operation is repeated. Given the sequence of consecutive operations, please output the resulting permutation after performing the operations.
Input
The first line contains two integers , indicating the length of permutation and the number of operations.
The second line contains operations, each operation is a string formed in or ().
Output
Output integers in one line, indicating the resulting permutation.
Samples
4 3
3a 2b 2a
2 1 3 4
Note
- After operation , the permutation becomes .
- After operation , the permutation becomes .
- After operation , the permutation becomes .
Resources
电子科技大学第十四届 ACM 趣味程序设计竞赛