#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 *, long);
int /*<<< orphan*/ scanf(char *, long *, ...);
int main() {
  long int t, i, k, n, x, l, j, q;
  scanf("%ld %ld %ld", &n, &k, &q);
  long int a[n], b[n];
  for (i = 0; i < n; i++)
    scanf("%ld", &a[(i + k) % n]);
  for (i = 0; i < q; i++) {
    scanf("%ld", &x);
    printf("%ld\n", a[x]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
lea    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    11c7 <main+0xa7>
mov    -0x68(%rbp),%rsi
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
cqto
idivq  -0x28(%rbp)
shl    $0x3,%rdx
add    %rdx,%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1181 <main+0x61>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x48(%rbp),%rax
jge    1218 <main+0xf8>
lea    0xe24(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x68(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11cf <main+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x50(%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    $0x28,%rsp
lea    0xec8(%rip),%rdi
xor    %ebx,%ebx
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x38(%rbp),%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rsp,%r12
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x30(%rbp),%rcx
test   %rcx,%rcx
jle    11b9 <main+0x99>
lea    0xe8e(%rip),%r14
jmp    11a0 <main+0x80>
nopl   0x0(%rax)
cqto
idiv   %rcx
lea    (%r12,%rdx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
mov    -0x30(%rbp),%rcx
cmp    %rcx,%rbx
jge    11b9 <main+0x99>
mov    -0x50(%rbp),%rax
add    %rbx,%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    1180 <main+0x60>
xor    %edx,%edx
div    %ecx
jmp    1185 <main+0x65>
cmpq   $0x0,-0x38(%rbp)
jle    1207 <main+0xe7>
lea    0xe41(%rip),%r14
lea    -0x48(%rbp),%r15
lea    0xe3a(%rip),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    -0x48(%rbp),%rax
mov    (%r12,%rax,8),%rsi
mov    %r13,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    -0x38(%rbp),%rbx
jl     11e0 <main+0xc0>
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 = [12 x i8] c"%ld %ld %ld\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
store i32 0, i32* %1
%13 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %5, i64* %4, i64* %9)
%14 = load i64, i64* %5
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %10
%16 = alloca i64, i64 %14
store i64 %14, i64* %11
%17 = load i64, i64* %5
%18 = alloca i64, i64 %17
store i64 %17, i64* %12
store i64 0, i64* %3
br label %19
19: ; preds = %31, %0
%20 = load i64, i64* %3
%21 = load i64, i64* %5
%22 = icmp slt i64 %20, %21
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = load i64, i64* %3
%25 = load i64, i64* %4
%26 = add nsw i64 %24, %25
%27 = load i64, i64* %5
%28 = srem i64 %26, %27
%29 = getelementptr inbounds i64, i64* %16, i64 %28
%30 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %29)
br label %31
31: ; preds = %23
%32 = load i64, i64* %3
%33 = add nsw i64 %32, 1
store i64 %33, i64* %3
br label %19
34: ; preds = %19
store i64 0, i64* %3
br label %35
35: ; preds = %45, %34
%36 = load i64, i64* %3
%37 = load i64, i64* %9
%38 = icmp slt i64 %36, %37
br i1 %38, label %39, label %48
39: ; preds = %35
%40 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %6)
%41 = load i64, i64* %6
%42 = getelementptr inbounds i64, i64* %16, i64 %41
%43 = load i64, i64* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %43)
br label %45
45: ; preds = %39
%46 = load i64, i64* %3
%47 = add nsw i64 %46, 1
store i64 %47, i64* %3
br label %35
48: ; preds = %35
store i32 0, i32* %1
%49 = load i8*, i8** %10
%50 = load i32, i32* %1
ret i32 %50
}

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