#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

### Shifting

#### Statement

You are given an array of N integers in and array A, you are supposed to do 3 different type of operations:

if the query is 1 i j

Shift the numbers in the array from Ai to Aj inclusive to the front

if the query is 2 i j

Shift the numbers in the array from Ai to Aj inclusive to the back

if the query is 0 i

Output the number at position i, 0-indexed

#### Input

First line contain 2 integers, N and Q;

Second line contains N integers of the array

Subsequent lines contain T, i, j. T is the query type

#### Output

If T is 0, output the number at that position, 0-indexed

#### Scoring

Subtask 1 (5%): N,Q <= 1000

Subtask 2 (15%): N,Q <= 10000

Subtask 3 (69%): N,Q <= 100000

Subtask 4 (11%): N,Q <= 500000

0 <= Ai <= 1000000000 (10^9)

0 <= i <= j < N

T = 0,1,2

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 5 | 10 | 3s | 512MB | Minimum |

2 | 15 | 10 | 3s | 512MB | Minimum |

3 | 69 | 10 | 3s | 512MB | Minimum |

4 | 11 | 7 | 3s | 512MB | Minimum |

### Judge Compile Command

g++ ans.cpp -o shifting -Wall -static -O2 -lm -m64 -s -w -std=gnu++14 -fmax-errors=512