John Watson knows of an operation called a right circular rotation on an array of integers.  One rotation operation moves the last array element to the first position and shifts all remaining elements right one.  To test Sherlock's abilities, Watson provides Sherlock with an array of integers.  Sherlock is to perform the rotation operation a number of times then determine the value of the element at a given position.

For each array, perform a number of right circular rotations and return the values of the elements at the given indices.

Example 

$a=[3,4,5]$ 

$k=2$ 

$queries=[1,2]$  

Here $\boldsymbol{\mbox{k}}$ is the number of rotations on $a$, and $qumeries$ holds the list of indices to report.  First we perform the two rotations: $[3,4,5]\rightarrow[5,3,4]\rightarrow[4,5,3]$  

Now return the values from the zero-based indices $1$ and $2$ as indicated in the $queries$ array. 

$a[1]=5$ 

$a[2]=3$  

Function Description  

Complete the circularArrayRotation function in the editor below.  

circularArrayRotation has the following parameter(s):  

int a[n]: the array to rotate  
int k: the rotation count  
int queries[1]: the indices to report  

Returns  

int[q]: the values in the rotated $a$ as requested in $m$

Input Format

The first line contains $3$ space-separated integers, $n$, $\boldsymbol{\mbox{k}}$, and $\textit{q}$, the number of elements in the integer array, the rotation count and the number of queries. 

The second line contains $n$ space-separated integers, where each integer $\boldsymbol{i}$ describes array element $a[i]$ (where $0\leq i<n$). 

Each of the $\textit{q}$ subsequent lines contains a single integer, $\textit{queries}[i]$, an index of an element in $a$ to return.

Constraints

$1\leq n\leq10^5$
$1\leq a[i]\leq10^5$
$1\leq k\leq10^5$
$1\leq q\leq500$    
$0\leq\textit{queries[i]}\lt n$

Sample Input 0
3 2 3
1 2 3
0
1
2

Sample Output 0
2
3
1

Explanation 0

After the first rotation, the array is $[3,1,2]$. 

After the second (and final) rotation, the array is $[2,3,1]$.   

We will call this final state array $b=[2,3,1]$. For each query, we just have to get the value of $b[queries[i]]$.

${q u eries[0]=0}$, $b[0]=2$.        
${q u eries[1]=1}$, $b[1]=3$.        
$queries[2]=2$, $b[2]=1$.

Difficulty: EASY

Solutions:
import sys
(N, K, Q) = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
for _ in range(Q):
	x = int(sys.stdin.readline())
	print(A[(x - K) % N])


(n, k, q) = input().split()
(n, k, q) = [int(n), int(k), int(q)]
a = list(map(int, input().split()))
k = k % n
b = a[n - k:]
del a[n - k:]
a = b + a
while q != 0:
	i = int(input())
	print(a[i])
	q -= 1


(N, K, Q) = input().strip().split()
arr = input().strip().split()
N = int(N)
K = int(K)
Q = int(Q)
if K >= N:
	K %= N
if K != 0:
	arr = arr[-K:] + arr[:-K]
for i in range(Q):
	print(arr[int(input())])


(N, K, Q) = map(int, input().strip().split())
arr = [int(x) for x in input().strip().split()]
positions = []
for pos in range(N):
	positions.append((pos + K) % N)
while Q > 0:
	q = int(input())
	print(arr[positions.index(q)])
	Q -= 1


from collections import deque
import io
inp = input()
inp = inp.split(' ')
n = int(inp[0])
k = int(inp[1])
q = int(inp[2])
inp = input()
a = inp.split(' ')
a = [int(i) for i in a]
d = deque(a)
d.rotate(k)
while q > 0:
	inp = int(input())
	print(d[inp])
	q = q - 1


(n, k, q) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
for i in range(q):
	Q = int(input())
	print(a[Q - k % n])


def nth_perm(v, n):
	l = len(v)
	a = [0] * l
	for i in range(0, l):
		a[(i + n) % l] = v[i]
	return a
a = [int(x) for x in input().split()]
n = a[0]
k = a[1]
q = a[2]
a = [int(x) for x in input().split()]
a = nth_perm(a, k)
for i in range(0, q):
	print(a[int(input())])


l1 = input()
s = l1.split(' ')
n = int(s[0])
k = int(s[1])
q = int(s[2])
lis = input().split(' ')
for i in range(int(q)):
	w = int(input())
	if w - k >= 0:
		print(lis[(w - k) % n])
	else:
		print(lis[(n + w - k) % n])


gr = input().split(' ')
n = int(gr[0])
k = int(gr[1])
q = int(gr[2])
arr = input().split(' ')
for asking in range(q):
	targ = (int(input()) - k) % n
	print(arr[targ])


(n, k, q) = map(int, input().split())
k = k % n
a = list(map(int, input().split()))
a = a[-k:] + a[:-k]
for i in range(q):
	x = int(input())
	print(a[x])


inp = input().split(' ')
N = int(inp[0])
K = int(inp[1])
Q = int(inp[2])
ar = input().split(' ')
for i in range(Q):
	index = int(input())
	print(int(ar[(index - K) % N]))


(arraySize, rotations, queries) = map(int, input().strip().split())
array = [int(x) for x in input().strip().split()]
for query in range(queries):
	print(array[(int(input()) - rotations) % arraySize])


info = input()
info_arr = info.split(' ')
values = input()
values_arr = values.split(' ')
count = 0
while count < int(info_arr[1]):
	temp = values_arr.pop()
	values_arr.insert(0, temp)
	count += 1
count = 0
while count < int(info_arr[2]):
	ch = input()
	num = int(ch)
	print(values_arr[num])
	count += 1


(N, K, Q) = map(int, input().split())
A = tuple(map(int, input().split()))
for _ in range(Q):
	print(A[(int(input()) + N - K) % N])


import sys

def rotate(array=[], k=0):
	if k > len(array):
		return rotate(rotate(array, len(array)), k - len(array))
	return array[-k:] + array[:-k]
data = sys.stdin.readlines()
init = data[0].split(' ')
_N = int(init[0])
_K = int(init[1])
_Q = int(init[2])
_queries = []
_array = [int(i.rstrip()) for i in data[1].split(' ')]
for i in range(2, _Q + 2):
	_queries.append(int(data[i].rstrip()))
_array = rotate(_array, _K)
for i in _queries:
	print(_array[i])


(n, k, q) = map(int, input().split())
a = input().split()
for i in range(q):
	print(a[(int(input()) - k) % n])


first_line = input()
(n, k, q) = first_line.split()
array = input()
array = array.split()
for i in range(int(q)):
	which = input()
	print(array[int(which) - int(k) % int(n)])


s = input().strip().split(' ')
n = int(s[0])
k = int(s[1])
q = int(s[2])
ar = input().strip().split(' ')
while q > 0:
	a = int(input())
	b = k % n
	a = a - b
	if a < 0:
		a = a + n
	print(ar[a])
	q -= 1


(N, K, Q) = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]
for i in range(Q):
	q = int(input())
	qt = (q - K % N + N) % N
	print(a[qt])


from collections import deque
(N, K, Q) = map(int, input().split())
A = deque(map(int, input().split()))
for i in range(K):
	A.appendleft(A.pop())
for i in range(Q):
	print(A[int(input())])


from collections import deque
(n, k, q) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
d = deque(a)
d.rotate(k)
a = list(d)
for i in range(q):
	x = int(input())
	print(a[x])


from collections import deque
(N, K, Q) = (int(i) for i in input().split())
lst = [int(i) for i in input().split()]
d = deque(lst)
for i in range(K):
	d.appendleft(d.pop())
rotated_list = list(d)
[print(rotated_list[int(input())]) for i in range(Q)]


(n, k, q) = [int(val) for val in input().split()]
arr = [int(val) for val in input().split()]
for i in range(q):
	query = int(input())
	index = (query - k) % len(arr)
	print(arr[index])


f = input().split()
n = int(f[0])
k = int(f[1])
q = int(f[2])
a = [int(x) for x in input().split()]
for i in range(q):
	x = (-k + int(input())) % n
	print(a[x])


(n, k, q) = tuple([int(i) for i in input().split(' ')])
arr = [int(i) for i in input().split(' ')]
for i in range(q):
	a = int(input())
	print(arr[(a - k + n) % n])


def sherlock(array, k, queries):
	k = k % len(array)
	array = array[-k:] + array[:-k]
	for q in queries:
		print(array[q])
(N, K, Q) = [int(x) for x in input().split()]
array_A = [int(x) for x in input().split()]
query = []
for i in range(0, Q):
	query.append(int(input().strip()))
sherlock(array_A, K, query)


import sys

def rightCircularRotation(array):
	array.insert(0, array.pop())
(first, array) = (sys.stdin.readline(), sys.stdin.readline().split())
(n, k, q) = first.split()
for _ in range(int(k)):
	rightCircularRotation(array)
for line in sys.stdin.readlines():
	print(array[int(line)], end='\n')


(n, k, q) = input().split()
q = int(q)
n = int(n)
k = int(k)
arr = [x for x in input().split()]
for i in range(q):
	t = int(input())
	print(arr[(t - k) % n])


inp = [int(a) for a in input().split()]
a = [int(a) for a in input().split()]
for i in range(inp[2]):
	x = int(input())
	print(a[(x - inp[1]) % inp[0]])


def reverse(numbers, lo, hi):
	i = lo
	j = hi
	while i < j:
		(numbers[i], numbers[j]) = (numbers[j], numbers[i])
		i += 1
		j -= 1
(n, k, q) = [int(i) for i in input().split(sep=' ')]
numbers = [int(i) for i in input().split(sep=' ')]
k = k % n
boundary = n - k
reverse(numbers, 0, boundary - 1)
reverse(numbers, boundary, n - 1)
reverse(numbers, 0, n - 1)
for _ in range(0, q):
	print(numbers[int(input())])


(N, K, Q) = [int(x) for x in input().split()]
A = input().split()
K = K % len(A)
A = A[-K:] + A[:-K]
for qq in range(Q):
	print(A[int(input())])


import sys
(n, k, q) = [int(x) for x in sys.stdin.readline().split()]
a = sys.stdin.readline().split()
i = 0
while i < q:
	x = (n + int(sys.stdin.readline()) - k) % n
	print(a[x])
	i += 1


def inArray(delim=' '):
	return [int(e) for e in input().strip().split(delim)]
(N, K, Q) = inArray()
X = inArray()
for q in range(Q):
	i = int(input())
	Ki = K - i
	if Ki <= 0:
		n = -Ki
	else:
		n = N - Ki
	print(X[n % N])


(N, K, Q) = list(map(int, input().split()))
A = list(map(int, input().split()))
newA = []
for i in range(N - K, 2 * N - K + 1):
	newA.append(A[i % N])
for _ in range(Q):
	index = int(input())
	print(newA[index])


(n, k, q) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
n = len(a)
b = [0] * n
for i in range(n):
	b[(i + k) % n] = a[i]
for i in range(q):
	y = int(input())
	print(b[y])


first = input().split(' ')
n = int(first[0])
k = int(first[1])
q = int(first[2])
arr = [int(s) for s in input().split(' ')]
for _ in range(q):
	x = int(input())
	print(arr[((x - k) % n + n) % n])


(n, k, q) = input().split()
n = int(n)
k = int(k)
q = int(q)
l = list(map(int, input().split()))
s = k % n
for i in range(0, q):
	x = input()
	x = int(x)
	print(l[x - s])


(N, K, Q) = map(int, input().split())
A = input().split()
for i in range(Q):
	print(A[(int(input()) - K) % N])


from collections import deque
(N, K, Q) = map(int, input().split())
ar = list(map(int, input().split()))
ar_q = []
for _ in range(Q):
	ar_q.append(int(input()))
ar = deque(ar)
ar.rotate(K)
for i in ar_q:
	print(ar[i])


import sys

def rotate(lst, k):
	n = len(lst)
	k = k % n
	lst = lst[n - k:] + lst[:n - k]
	return lst

def do():
	(n, k, q) = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]
	lst = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]
	lst = rotate(lst, k)
	result = [lst[int(i)] for i in sys.stdin.readlines()]
	for i in result:
		print(i)
do()


import sys
(N, K, Q) = tuple((int(x) for x in sys.stdin.readline().strip().split()))
K = K % N
data = [int(x) for x in sys.stdin.readline().strip().split()]
if K > 0:
	data = data[-K:] + data[:N - K]
for _ in range(Q):
	i = int(sys.stdin.readline().strip())
	print(data[i])


def sherlock_and_watson():
	(N, K, Q) = [int(i) for i in input().split()]
	array = [int(j) for j in input().split()]
	x_vals = []
	for k in range(Q):
		x_vals.append(int(input()))
	for m in range(K):
		array.insert(0, array.pop(-1))
	for val in x_vals:
		print(array[val])
sherlock_and_watson()


class CircularArray:

	def __init__(self, data, k):
		self._data = data

	def __getitem__(self, index):
		return self._data[(index - k) % len(self._data)]
(_, k, num_q) = [int(num) for num in input().strip().split()]
nums = [int(num) for num in input().strip().split()]
ca = CircularArray(nums, k)
for _ in range(num_q):
	spec_item = int(input())
	print(ca[spec_item])


test = str(input())
test = test.split()
test = list(map(int, test))
array = str(input())
array = array.split()
array = list(map(int, array))
lst = []
for i in range(test[2]):
	pos = int(input())
	lst.append(pos)
if len(array) <= test[1]:
	leng = len(array) - test[1] % len(array)
else:
	leng = len(array) - test[1]
b = array[leng:]
c = array[:leng]
a = b + c
lst.reverse()
while len(lst) != 0:
	print(a[lst.pop()])


line1 = input().split(' ')
N = int(line1[0])
K = int(line1[1])
Q = int(line1[2])
oldList = input().split(' ')
newList = [0 for x in range(N)]
for i in range(N):
	index = (int(i) + K) % N
	newList[index] = oldList[int(i)]
for x in range(Q):
	print(newList[int(input())])


(N, K, Q) = [int(x) for x in input().split()]
arr = input().split()
K = -(K % N)
arr = arr[K:] + arr[:K]
for _ in range(Q):
	print(arr[int(input())])


(n, k, q) = input().split()
n = int(n)
k = int(k)
q = int(q)
lst = [int(c) for c in input().split()]
if k > n:
	k = k % n
lst = lst[-k:] + lst[:-k]
for i in range(q):
	inp = int(input())
	print(lst[inp])


tmp = input().split()
(n, k, q) = (int(tmp[0]), int(tmp[1]), int(tmp[2]))
a = list(map(int, input().split()))
for j in range(0, q):
	i = int(input())
	if i < 0:
		t = int(abs(i / n)) + 1
		i = i + n * t
	tmp = a[(i - k + n) % n]
	print(str(tmp))


(N, K, Q) = (int(_) for _ in input().split())
A = [int(_) for _ in input().split()]
for _ in range(Q):
	print(A[(int(input()) - K) % N])


NKQ = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
temp = []
dic = {i: None for i in range(0, len(A))}
for i in range(0, len(A)):
	index = (i + NKQ[1]) % NKQ[0]
	dic[index] = A[i]
for i in range(NKQ[2]):
	n = int(input().strip())
	print(dic[n])


from collections import deque
(n, k, q) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
aRotate = deque(a)
aRotate.rotate(k)
for _ in range(q):
	i = int(input())
	print(aRotate[i])


def do_k_rots(arr, arr_siz, k):
	new_arr = [0] * arr_siz
	for i in range(0, arr_siz):
		new_arr[(i + k) % arr_siz] = arr[i]
	return new_arr
(arr_siz, k_rot, n_queries) = map(int, input().split())
arr = list(map(int, input().split()))
queries = [int(input()) for i in range(n_queries)]
arr = do_k_rots(arr, arr_siz, k_rot)
for qi in queries:
	print(arr[qi])


from sys import stdin
(array_size, rotations_count, queries_count) = list(map(int, stdin.readline().split()))
array = list(map(int, stdin.readline().split()))
for query_number in range(queries_count):
	query_index = int(stdin.readline())
	element_index = (query_index - rotations_count) % array_size
	print(array[element_index])


(N, K, Q) = map(int, input().split())
ar = [int(i) for i in input().split()]
for i in range(0, Q):
	q = int(input())
	qinv = (q - K) % N
	print(ar[qinv])


def main():
	inp_str = input()
	(n, k, q) = map(int, inp_str.split())
	inp_str = input()
	a = list(map(int, inp_str.split()))
	for i in range(q):
		j = int(input())
		print('{}'.format(a[(j - k) % n]))
main()


(N, K, Q) = map(int, input().split())
ar = list(map(int, input().split()))
K = K % N
ar = ar[-K:] + ar[:-K]
for test in range(Q):
	i = int(input())
	print(ar[i])


(N, K, Q) = [int(i) for i in input().split()]
li = [int(i) for i in input().split()]
for _ in range(Q):
	print(li[(int(input()) - K) % N])


import sys
testInfo = sys.stdin.readline().strip().split()
leng = int(testInfo[0])
rotations = int(testInfo[1])
lines = int(testInfo[2])
lst = sys.stdin.readline().strip().split()
lst = list(map(int, lst))
for i in range(lines):
	pos = int(sys.stdin.readline())
	pos = pos - rotations
	if pos < -leng:
		pos = pos % leng
	print(lst[pos])


(N, K, Q) = list(map(int, input().split()))
L = list(map(int, input().split()))
for i in range(Q):
	x = int(input())
	s = x
	x -= K
	if x < 0:
		while x < 0:
			x += N
	print(L[x])


(n, k, q) = map(int, input().split())
a = list(map(int, input().split()))
for x in range(q):
	print(a[(int(input()) - k) % n])


__author__ = 'danielbaeck'
(n, k, q) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]

def rotate(l, t):
	t = t % len(l)
	return l[-t:] + l[:-t]
arr = rotate(arr, k)
for i in range(q):
	c = int(input())
	print(arr[c])


(N, K, Q) = (int(n) for n in input().split())
arr = tuple((int(n) for n in input().split()))
for q in range(Q):
	x = int(input())
	print(arr[(x + N - K) % N])


(n, k, q) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
for i in range(q):
	print(a[(int(input()) - k) % n])


input1 = input().split()
N = int(input1[0])
K = int(input1[1])
Q = int(input1[2])
inArray = [int(x) for x in input().split()]
for i in range(K):
	inArray.insert(0, inArray.pop(len(inArray) - 1))
for i in range(Q):
	print(str(inArray[int(input())]))


(N, K, Q) = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(Q):
	print(A[(int(input()) - K) % N])


(N, K, Q) = [int(c) for c in input().split(' ')]
A = [int(c) for c in input().split(' ')]
for q in range(Q):
	x = int(input())
	res = A[(x - K + N) % N]
	print(res)


(N, K, Q) = input().split()
n = int(N)
k = int(K)
q = int(Q)
A = list(input().split())
queries = []
for i in range(q):
	queries.append(int(input()))
for i in range(k):
	exchange = A[len(A) - 1]
	A.pop()
	A.insert(0, exchange)
for i in queries:
	print(A[i])


(n, k, q) = [int(x) for x in input().strip().split()]
ar = [int(x) for x in input().strip().split()]
k = k % n
pre = n - k
for i in range(q):
	index = int(input())
	print(ar[(pre + index) % n])


(n, k, q) = [int(i) for i in input().split()]
a = list(map(int, input().split()))
for i in range(q):
	x = int(input())
	index = (n + x - k) % n
	print(a[index])


(n, k, q) = [int(num) for num in input().strip().split()]
numbers = input().strip().split()
k = k % n
new_numbers = []
for i in range(k):
	new_numbers.append(numbers[n - k + i])
for i in range(n - k):
	new_numbers.append(numbers[i])
for t in range(q):
	num = int(input().strip())
	print(new_numbers[num])


def main():
	(n, k, q) = [int(x) for x in str(input()).split()]
	numbers = str(input()).split()
	numbers = rcr(numbers, k % len(numbers))
	for i in range(q):
		print(numbers[int(input())])

def rcr(n, k):
	return n[len(n) - k:] + n[0:len(n) - k]
main()


nkq = [int(x) for x in input().split()]
array = [int(x) for x in input().split()]
queries = []
for idx in range(nkq[2]):
	queries.append(int(input()))
n = nkq[0]
k = nkq[1]
arr_len = len(array)
for q in queries:
	idx = q - k % len(array)
	idx = idx if idx >= 0 else idx + n
	print(array[idx])


(n, k, q) = map(int, input().split())
k = k % n
a = input().split()
for i in range(q):
	x = int(input()) - k
	print(a[x % n])


def main():
	nkq = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	r = nkq[1] % nkq[0]
	for i in range(nkq[2]):
		q = int(input())
		t = q - r if r <= q else nkq[0] + q - r
		print(arr[t])
main()


(n, k, q) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
for _ in range(q):
	x = int(input().strip())
	i = (x + n - k) % n
	print(a[i])


def run():
	(n, k, q) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	while q > 0:
		q -= 1
		x = int(input())
		print(a[(x + n - k) % n])
run()


def query(ar, n, i):
	i = (i - n) % len(ar)
	return ar[i]
(n, k, q) = map(int, input().split())
a = list(map(int, input().split()))
queries = [int(input()) for i in range(q)]
results = [query(a, k, qq) for qq in queries]
for r in results:
	print(r)


import sys
(n, k, q) = [int(s) for s in sys.stdin.readline().split()]
a = [int(s) for s in sys.stdin.readline().split()]
xs = [int(s) for s in sys.stdin.readlines()]
for x in xs:
	new_x = (x - k) % n
	print(a[new_x])


In = [int(x) for x in input().split(' ')]
n = In[0]
k = In[1]
q = In[2]
A = [int(x) for x in input().split(' ')]
while k >= len(A):
	k -= len(A)
A = A[-k:] + A[:-k]
for i in range(q):
	i = int(input())
	print(A[i])


(length, ops, qs) = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
delta = ops % length
for _ in range(qs):
	index = int(input())
	print(nums[index - delta])


(n, k, q) = [int(x) for x in input().split()]
ar = [int(x) for x in input().split()]
new_start = (0 - k) % n
ar = ar[new_start:] + ar[:new_start]
for _ in range(q):
	i = int(input())
	print(ar[i])


def getRotated(A, K, x):
	index = (x - K) % len(A)
	return A[index]
(N, K, Q) = map(int, input().split())
A = [int(item) for item in input().split()]
for q in range(Q):
	x = int(input())
	print(getRotated(A, K, x))


input1 = input()
input2 = list(map(int, input1.split()))
N = int(input2[0])
K = int(input2[1])
Q = int(input2[2])
input3 = input()
data = list(map(int, input3.split()))
for x in range(0, K):
	data.insert(0, data[N - 1])
	del data[N]
Z = []
for y in range(0, Q):
	Z.append(int(input()))
for i in range(0, Q):
	print(data[Z[i]])


def rotate(ar, shift):
	for i in range(shift):
		n = ar.pop()
		ar.insert(0, n)
	return ar
items = input()
(list_length, shift, num_outputs) = [int(x) for x in items.split(' ')]
ar = input()
ar = [int(x) for x in ar.split(' ')]
ans = rotate(ar, shift)
for i in range(num_outputs):
	a = int(input())
	print(ans[a])


(N, K, Q) = map(int, input().split())
A = input().split()
for i in range(Q):
	print(A[(int(input()) - K) % N])


(n, k, q) = map(int, input().strip().split())
numbers = [int(x) for x in input().strip().split()]
for _ in range(q):
	i = int(input())
	i -= k
	i %= n
	print(numbers[i])


line1 = input()
line1 = [int(x) for x in line1.split(' ')]
(length, rotations, queries) = (line1[0], line1[1], line1[2])
nums = [int(x) for x in input().split(' ')]

def rotate(nums):
	last = nums[length - 1]
	nums.pop(length - 1)
	nums.insert(0, last)

def process_query(index):
	return nums[index]
for _ in range(rotations):
	rotate(nums)
for query in range(queries):
	print(process_query(int(input())))


(N, K, Q) = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(Q):
	x = int(input())
	K = K % N
	print(A[((N - K) % N + x) % N])


first_line = input().split(' ')
array_len = int(first_line[0])
rotation_val = int(first_line[1])
queries = int(first_line[2])
given_list = input().split(' ')
given_list = [int(x) for x in given_list]
query_list = []
if rotation_val > array_len:
	rotation_val = rotation_val % array_len
for i in range(queries):
	query_list.append(input())
query_list = [int(x) for x in query_list]
for query in query_list:
	adjusted_index = query - rotation_val
	print(given_list[adjusted_index])


def main():
	line = input().rstrip().split()
	N = int(line[0])
	K = int(line[1])
	Q = int(line[2])
	list0 = input().rstrip().split()
	for i in range(Q):
		index0 = int(input())
		newindex = (index0 - K) % N
		print(list0[newindex])
main()


(n, k, q) = [int(x) for x in input().split(' ')]
ar = [int(x) for x in input().split(' ')]
k = k % n
s = ar[:n - k]
b = ar[n - k:]
for x in s:
	b.append(x)
for _ in range(q):
	x = int(input())
	print(b[x])


inputNum = list(map(int, input().split(' ')))
(n, k, q) = (inputNum[0], inputNum[1], inputNum[2])
array = list(map(int, input().split(' ')))
for i in range(0, k):
	array.insert(0, array.pop())
for i in range(0, q):
	index = int(input())
	print(array[index])


(n, k, q) = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]
queries = [int(input()) for _ in range(q)]
k = k % n
for query_idx in queries:
	original_idx = (n + query_idx - k) % n
	print(array[original_idx])


(N, K, Q) = map(int, input().split())
nums = list(map(int, input().split()))
for _ in range(Q):
	find = int(input())
	K = K % N
	print(nums[find - K])


import sys
(N, K, Q) = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
for _ in range(Q):
	x = int(sys.stdin.readline())
	print(A[(x - K) % N])