#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 */
scalar_t__ malloc(long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *);
int main() {
  long long n, k, q, i;
  long long *arr, idx;
  scanf("%llu", &n);
  scanf("%llu", &k);
  scanf("%llu", &q);
  arr = (long long *)malloc(n * sizeof(long long));
  for (i = 0; i < n; i++) {
    scanf("%llu", (arr + i));
  }
  printf("Answer:%d", (1 - 2 % 3));
  while (q != 0) {
    scanf("%llu", &idx);
    idx = (idx - k) % n;
    if (idx < 0)
      idx = n + idx;
    printf("Index :%lld\n", idx);
    printf("eLEMENT:%llu\n", arr[idx]);
    --q;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11c2 <main+0x92>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe54(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1188 <main+0x58>
lea    0xe3c(%rip),%rdi
mov    $0xffffffffffffffff,%rsi
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1252 <main+0x122>
lea    0xe19(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x38(%rbp),%rax
sub    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jge    1219 <main+0xe9>
mov    -0x10(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdeb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xde0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <main+0xa5>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebb(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
cmpq   $0x0,0x8(%rsp)
jle    11ba <main+0x8a>
xor    %ebx,%ebx
lea    0xe72(%rip),%r15
mov    %r14,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
add    $0x8,%rbp
cmp    0x8(%rsp),%rbx
jl     11a0 <main+0x70>
lea    0xe44(%rip),%rdi
mov    $0xffffffffffffffff,%rsi
call   1030 <printf@plt>
cmpq   $0x0,0x18(%rsp)
je     1264 <main+0x134>
lea    0xe20(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xe23(%rip),%r12
lea    0xe29(%rip),%r13
jmp    1238 <main+0x108>
cs nopw 0x0(%rax,%rax,1)
nop
cqto
idiv   %rcx
mov    %rdx,%rsi
sar    $0x3f,%rsi
and    %rcx,%rsi
add    %rdx,%rsi
mov    %rsi,0x10(%rsp)
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rax
mov    (%r14,%rax,8),%rsi
mov    %r13,%rdi
call   1030 <printf@plt>
addq   $0xffffffffffffffff,0x18(%rsp)
je     1264 <main+0x134>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%rax
sub    0x20(%rsp),%rax
mov    0x8(%rsp),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    1200 <main+0xd0>
xor    %edx,%edx
div    %ecx
jmp    1205 <main+0xd5>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [10 x i8] c"Answer:%d\00"
@.str.2 = [13 x i8] c"Index :%lld\0A\00"
@.str.3 = [14 x i8] c"eLEMENT:%llu\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
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %4)
%11 = load i64, i64* %2
%12 = mul i64 %11, 8
%13 = call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i64*
store i64* %14, i64** %6
store i64 0, i64* %5
br label %15
15: ; preds = %24, %0
%16 = load i64, i64* %5
%17 = load i64, i64* %2
%18 = icmp slt i64 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i64*, i64** %6
%21 = load i64, i64* %5
%22 = getelementptr inbounds i64, i64* %20, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %22)
br label %24
24: ; preds = %19
%25 = load i64, i64* %5
%26 = add nsw i64 %25, 1
store i64 %26, i64* %5
br label %15
27: ; preds = %15
%28 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 -1)
br label %29
29: ; preds = %45, %27
%30 = load i64, i64* %4
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %55
32: ; preds = %29
%33 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %7)
%34 = load i64, i64* %7
%35 = load i64, i64* %3
%36 = sub nsw i64 %34, %35
%37 = load i64, i64* %2
%38 = srem i64 %36, %37
store i64 %38, i64* %7
%39 = load i64, i64* %7
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %32
%42 = load i64, i64* %2
%43 = load i64, i64* %7
%44 = add nsw i64 %42, %43
store i64 %44, i64* %7
br label %45
45: ; preds = %41, %32
%46 = load i64, i64* %7
%47 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %46)
%48 = load i64*, i64** %6
%49 = load i64, i64* %7
%50 = getelementptr inbounds i64, i64* %48, i64 %49
%51 = load i64, i64* %50
%52 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i64 %51)
%53 = load i64, i64* %4
%54 = add nsw i64 %53, -1
store i64 %54, i64* %4
br label %29
55: ; preds = %29
%56 = load i32, i32* %1
ret i32 %56
}

LLVM IR (-O2):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [10 x i8] c"Answer:%d\00"
@.str.2 = [13 x i8] c"Index :%lld\0A\00"
@.str.3 = [14 x i8] c"eLEMENT:%llu\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 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%12 = load i64, i64* %1
%13 = shl i64 %12, 3
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i64*
%16 = load i64, i64* %1
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %0, %18
%19 = phi i64 [ %22, %18 ], [ 0, %0 ]
%20 = getelementptr inbounds i64, i64* %15, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i64, i64* %1
%24 = icmp slt i64 %22, %23
br i1 %24, label %18, label %25
25: ; preds = %18, %0
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 -1)
%27 = load i64, i64* %3
%28 = icmp eq i64 %27, 0
br i1 %28, label %47, label %29
29: ; preds = %25, %29
%30 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %4)
%31 = load i64, i64* %4
%32 = load i64, i64* %2
%33 = sub nsw i64 %31, %32
%34 = load i64, i64* %1
%35 = srem i64 %33, %34
%36 = icmp slt i64 %35, 0
%37 = select i1 %36, i64 %34, i64 0
%38 = add nsw i64 %35, %37
store i64 %38, i64* %4
%39 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %38)
%40 = load i64, i64* %4
%41 = getelementptr inbounds i64, i64* %15, i64 %40
%42 = load i64, i64* %41
%43 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i64 %42)
%44 = load i64, i64* %3
%45 = add nsw i64 %44, -1
store i64 %45, i64* %3
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %29
47: ; preds = %29, %25
ret i32 0
}