#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n, k, q, x, i;
  scanf("%d%d%d", &n, &k, &q);
  int a[n];
  for (i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  for (i = 0, k %= n; i < q; ++i) {
    scanf("%d", &x);
    printf("%d\n", a[(x - k + n) % n]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ae <main+0x8e>
mov    -0x30(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1177 <main+0x57>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1210 <main+0xf0>
lea    0xe30(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c1 <main+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
jle    119e <main+0x7e>
lea    0xe8f(%rip),%r14
mov    %r13,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rcx
add    $0x4,%r15
cmp    %rcx,%rbx
jl     1180 <main+0x60>
mov    -0x30(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    1205 <main+0xe5>
lea    0xe50(%rip),%r14
lea    -0x38(%rbp),%r15
lea    0xe48(%rip),%rbx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltd
idiv   %ecx
movslq %edx,%rax
mov    0x0(%r13,%rax,4),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x1,%r12d
cmp    -0x34(%rbp),%r12d
jl     11d0 <main+0xb0>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d%d%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i32, i64 %11
store i64 %11, i64* %8
store i32 0, i32* %6
br label %14
14: ; preds = %23, %0
%15 = load i32, i32* %6
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %13, i64 %20
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %14
26: ; preds = %14
store i32 0, i32* %6
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = srem i32 %28, %27
store i32 %29, i32* %3
br label %30
30: ; preds = %47, %26
%31 = load i32, i32* %6
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %50
34: ; preds = %30
%35 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%36 = load i32, i32* %5
%37 = load i32, i32* %3
%38 = sub nsw i32 %36, %37
%39 = load i32, i32* %2
%40 = add nsw i32 %38, %39
%41 = load i32, i32* %2
%42 = srem i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %13, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %34
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %30
50: ; preds = %30
store i32 0, i32* %1
%51 = load i8*, i8** %7
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d%d%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%10 = load i32, i32* %1
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
%13 = alloca i32, i64 %11
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %0, %16
%17 = phi i64 [ %20, %16 ], [ 0, %0 ]
%18 = getelementptr inbounds i32, i32* %13, i64 %17
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = add nuw nsw i64 %17, 1
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %16, label %24
24: ; preds = %16, %0
%25 = phi i32 [ %14, %0 ], [ %21, %16 ]
%26 = load i32, i32* %2
%27 = srem i32 %26, %25
store i32 %27, i32* %2
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %46
30: ; preds = %24, %30
%31 = phi i32 [ %43, %30 ], [ 0, %24 ]
%32 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%33 = load i32, i32* %4
%34 = load i32, i32* %2
%35 = sub i32 %33, %34
%36 = load i32, i32* %1
%37 = add nsw i32 %35, %36
%38 = srem i32 %37, %36
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %13, i64 %39
%41 = load i32, i32* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = add nuw nsw i32 %31, 1
%44 = load i32, i32* %3
%45 = icmp slt i32 %43, %44
br i1 %45, label %30, label %46
46: ; preds = %30, %24
ret i32 0
}