Find the element at given index
##### Submissions: 1066   Accuracy: 29.14%   Difficulty: Medium   Marks: 4

Given an array arr[] of N elements. Perform K right circular rotations on given ranges [L..R]. After performing these rotations, we need to find element at a given index X.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of three lines. First line of each test case contains three integers N, X  and K. Second line contains N space separated array elements and next line contains K ranges [L, R] (space seperated) on which we have to rotate the array in right circular manner.

Output:
For each test case, print the array[X] (0-based indexing)element after K rotations in new line.

Constraints:
1 <= T <= 500
2 <= N <= 105

1 <= arr[] <= 105
1 <= K <= 105
X < N
0 <= L <= R

Example:
Input:

2
5 1 2
1 2 3 4 5
0 2 0 3
3 2 1
1 2 3
0 1

Output:
3
3

Explanation:
Testcase 1:
Rotating the elements in range 0-2 and 0-3, we have array as 4 3 1 2 5. Element at first position is 3.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: arun03

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.