#ABC4103. Rotatable Array
Rotatable Array
C - Rotatable Array /
Problem Statement
There is an integer sequence of length , initially . Process a total of Q queries of the following types:
Type 1: Change to .
Type 2: Output .
Type 3: Repeat the operation "move the first element of to the end" times.
Formally, replace A with times.
Constraints
All input values are integers.
All queries satisfy the following constraints:
Input
The input is given from Standard Input in the following format:
⋮
Here, represents the query.
Type 1 queries are given in the following format: 1 p x Type 2 queries are given in the following format: 2 p Type 3 queries are given in the following format: 3 k Output For each Type 2 query, output the answer on a line.
Sample Input 1
5 5
2 3
1 2 1000000
3 4
2 2
2 3
Sample Output 1
3
1
1000000
This input contains 5 queries.
Initially, A=(1,2,3,4,5).
The 1st query is Type 2: output A 3 =3.
The 2nd query is Type 1: replace A 2 with 1000000.
After the query, A=(1,1000000,3,4,5).
The 3rd query is Type 3: repeat the operation "move the first element of A to the end"
4 times.
After the query, A=(5,1,1000000,3,4).
The 4th query is Type 2: output A 2 =1.
The 5th query is Type2: output A 3 =1000000.
Sample Input 2
1000000 2
1 1000000 999999
3 1000000000
Sample Output 2
The output may be empty.