#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 findInfimumInd(int *, int, int);
int findSupremumInd(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main(void) {
  int sortedHeight[50000], mSize, numQuery, query, height, i, supremumInd,
      infimumInd;
  while (scanf("%d", &mSize) > 0) {
    for (i = 0; i < mSize; i++)
      scanf("%d", &sortedHeight[i]);
    scanf("%d", &numQuery);
    for (query = 0; query < numQuery; query++) {
      scanf("%d", &height);
      supremumInd = findSupremumInd(sortedHeight, mSize, height);
      infimumInd = findInfimumInd(sortedHeight, mSize, height);
      if (infimumInd < 0)
        printf("X ");
      else
        printf("%d ", sortedHeight[infimumInd]);
      if (supremumInd < 0)
        printf("X\n");
      else
        printf("%d\n", sortedHeight[supremumInd]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30d70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x30d54(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x0,%rax
jle    12d4 <main+0x194>
movl   $0x0,-0x30d64(%rbp)
mov    -0x30d64(%rbp),%eax
cmp    -0x30d54(%rbp),%eax
jge    11c0 <main+0x80>
movslq -0x30d64(%rbp),%rax
lea    -0x30d50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe59(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x30d64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30d64(%rbp)
jmp    1179 <main+0x39>
lea    0xe39(%rip),%rdi
lea    -0x30d58(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x30d5c(%rbp)
mov    -0x30d5c(%rbp),%eax
cmp    -0x30d58(%rbp),%eax
jge    12cf <main+0x18f>
lea    0xe0a(%rip),%rdi
lea    -0x30d60(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x30d50(%rbp),%rdi
mov    -0x30d54(%rbp),%esi
mov    -0x30d60(%rbp),%edx
call   1030 <findSupremumInd@plt>
mov    %eax,-0x30d68(%rbp)
lea    -0x30d50(%rbp),%rdi
mov    -0x30d54(%rbp),%esi
mov    -0x30d60(%rbp),%edx
call   1050 <findInfimumInd@plt>
mov    %eax,-0x30d6c(%rbp)
cmpl   $0x0,-0x30d6c(%rbp)
jge    125e <main+0x11e>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127a <main+0x13a>
movslq -0x30d6c(%rbp),%rax
mov    -0x30d50(%rbp,%rax,4),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x30d68(%rbp)
jge    129a <main+0x15a>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b6 <main+0x176>
movslq -0x30d68(%rbp),%rax
mov    -0x30d50(%rbp,%rax,4),%esi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bb <main+0x17b>
mov    -0x30d5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30d5c(%rbp)
jmp    11dd <main+0x9d>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x30d70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30d58,%rsp
lea    0xe98(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
test   %rax,%rax
jle    129c <main+0x14c>
lea    0x10(%rsp),%r14
lea    0xe79(%rip),%r13
lea    0x8(%rsp),%r12
lea    0xe70(%rip),%rbx
jmp    11b6 <main+0x66>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
test   %rax,%rax
jle    129c <main+0x14c>
mov    %rbx,%r15
cmpl   $0x0,0x4(%rsp)
jle    11ed <main+0x9d>
mov    %r14,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%rbx
jl     11d0 <main+0x80>
mov    %r13,%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
mov    %r15,%rbx
jle    11a0 <main+0x50>
xor    %r15d,%r15d
jmp    1233 <main+0xe3>
nopl   0x0(%rax)
mov    %ebp,%eax
mov    0x10(%rsp,%rax,4),%esi
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15d
cmp    0xc(%rsp),%r15d
jge    11a0 <main+0x50>
mov    %r13,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
call   1030 <findSupremumInd@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
call   1060 <findInfimumInd@plt>
test   %eax,%eax
js     1280 <main+0x130>
mov    %eax,%eax
mov    0x10(%rsp,%rax,4),%esi
lea    0xd95(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jns    1210 <main+0xc0>
jmp    128e <main+0x13e>
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jns    1210 <main+0xc0>
lea    0xd79(%rip),%rdi
call   1040 <puts@plt>
jmp    1224 <main+0xd4>
xor    %eax,%eax
add    $0x30d58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"X \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [3 x i8] c"X\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50000 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
br label %10
10: ; preds = %67, %0
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %68
13: ; preds = %10
store i32 0, i32* %7
br label %14
14: ; preds = %23, %13
%15 = load i32, i32* %7
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [50000 x i32], [50000 x i32]* %2, i64 0, i64 %20
%22 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %14
26: ; preds = %14
%27 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %5
br label %28
28: ; preds = %64, %26
%29 = load i32, i32* %5
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %67
32: ; preds = %28
%33 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%34 = getelementptr inbounds [50000 x i32], [50000 x i32]* %2, i64 0, i64 0
%35 = load i32, i32* %3
%36 = load i32, i32* %6
%37 = call i32 @findSupremumInd(i32* %34, i32 %35, i32 %36)
store i32 %37, i32* %8
%38 = getelementptr inbounds [50000 x i32], [50000 x i32]* %2, i64 0, i64 0
%39 = load i32, i32* %3
%40 = load i32, i32* %6
%41 = call i32 @findInfimumInd(i32* %38, i32 %39, i32 %40)
store i32 %41, i32* %9
%42 = load i32, i32* %9
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %52
46: ; preds = %32
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [50000 x i32], [50000 x i32]* %2, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %46, %44
%53 = load i32, i32* %8
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %63
57: ; preds = %52
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [50000 x i32], [50000 x i32]* %2, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %57, %55
br label %64
64: ; preds = %63
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
br label %28
67: ; preds = %28
br label %10
68: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"X \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"X\00"
define i32 @main() {
%1 = alloca [50000 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [50000 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %61
11: ; preds = %0
%12 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 0
br label %16
13: ; preds = %57, %27
%14 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %61
16: ; preds = %11, %13
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %16, %19
%20 = phi i64 [ %23, %19 ], [ 0, %16 ]
%21 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 %20
%22 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = add nuw nsw i64 %20, 1
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %19, label %27
27: ; preds = %19, %16
%28 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %13
31: ; preds = %27, %57
%32 = phi i32 [ %58, %57 ], [ 0, %27 ]
%33 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%34 = load i32, i32* %2
%35 = load i32, i32* %4
%36 = call i32 @findSupremumInd(i32* %12, i32 %34, i32 %35)
%37 = load i32, i32* %2
%38 = load i32, i32* %4
%39 = call i32 @findInfimumInd(i32* %12, i32 %37, i32 %38)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %31
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %48
43: ; preds = %31
%44 = zext i32 %39 to i64
%45 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %43, %41
%49 = icmp slt i32 %36, 0
br i1 %49, label %50, label %52
50: ; preds = %48
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %57
52: ; preds = %48
%53 = zext i32 %36 to i64
%54 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %50, %52
%58 = add nuw nsw i32 %32, 1
%59 = load i32, i32* %3
%60 = icmp slt i32 %58, %59
br i1 %60, label %31, label %13
61: ; preds = %13, %0
ret i32 0
}