Your friend, Jackson is invited to a TV show called SuperMemo in which the participant is told to play a memorizing game. At first, the host tells the participant a sequence of numbers, {*A*_{1}, *A*_{2}, ... *A*_{n}}. Then the host performs a series of operations and queries on the sequence which consists:

*ADD x y D*: Add D to each number in sub-sequence {*A*..._{x}*A*}. For example, performing "_{y}*ADD*2 4 1" on {1, 2, 3, 4, 5} results in {1, 3, 4, 5, 5}*REVERSE x y*: reverse the sub-sequence {*A*..._{x}*A*}. For example, performing "_{y}*REVERSE*2 4" on {1, 2, 3, 4, 5} results in {1, 4, 3, 2, 5}*REVOLVE x y T*: rotate sub-sequence {*A*..._{x}*A*}_{y}*T*times. For example, performing "*REVOLVE*2 4 2" on {1, 2, 3, 4, 5} results in {1, 3, 4, 2, 5}*INSERT x P*: insert*P*after*A*. For example, performing "_{x}*INSERT*2 4" on {1, 2, 3, 4, 5} results in {1, 2, 4, 3, 4, 5}*DELETE x*: delete*A*. For example, performing "_{x}*DELETE*2" on {1, 2, 3, 4, 5} results in {1, 3, 4, 5}*MIN x y*: query the participant what is the minimum number in sub-sequence {*A*..._{x}*A*}. For example, the correct answer to "_{y}*MIN*2 4" on {1, 2, 3, 4, 5} is 2

提交代码