# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13442 | Lucky money 2 |
|
Description
Receiving lucky money is the favorite activity of children during Chinese New Year.
Denny's family has N children, everyone wants to get the lucky money as soon as possible.
The elders in the family have prepared a game to decide the order of receiving the lucky money:
- At the beginning, all children sit in a circle, with seats numbered from 1 to N.
- Randomly decide two numbers A and K and the direction R/L, move the Ath youngest child K positions clockwise/counterclockwise.
For example:
N = 6
The given initial age sequence: 1 1 3 4 5 5
A = 3, K = 2, R
After processing:
A = 1, K = 3, L
After processing:
A = 1, K = 6, R
After processing:
A = 2, K = 2, R
After processing:
Output:
The age sequence in clockwise from the youngest: 1 3 5 4 5 1
Note: if two children have same age, consider the children with less order yonger.
Input
The first line contains two integers N M, the number of children and the number of position changes.
The second line contains N integers, giving the children's age sequence.
Each of the following M lines contains two integers A and K and the direction 'R' or 'L'.
test cases:
Output
The output contains one line.
Output the age sequence of the children in clockwise from the youngest.