#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__ EOF;
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int tree[1001];
  int n, i, height, start, end;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < 1001; i++)
      tree[i] = -1;
    for (i = 0; i < n; i++)
      scanf("%d", &tree[i]);
    scanf("%d", &height);
    start = pow(2, height - 1) - 1;
    end = start * 2 + 1;
    if (height == 1 || n - start == 1) {
      printf("%d\n", tree[start]);
      continue;
    } else if (start > n) {
      printf("EMPTY\n");
      continue;
    } else
      printf("%d", tree[start]);
    for (i = start + 1; i < end && i < n; i++)
      printf(" %d", tree[i]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec3(%rip),%rdi
lea    -0xfb4(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
je     1354 <main+0x224>
movl   $0x0,-0xfb8(%rbp)
cmpl   $0x3e9,-0xfb8(%rbp)
jge    11a5 <main+0x75>
movslq -0xfb8(%rbp),%rax
movl   $0xffffffff,-0xfb0(%rbp,%rax,4)
ff ff ff ff
mov    -0xfb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb8(%rbp)
jmp    116f <main+0x3f>
movl   $0x0,-0xfb8(%rbp)
mov    -0xfb8(%rbp),%eax
cmp    -0xfb4(%rbp),%eax
jge    11f6 <main+0xc6>
movslq -0xfb8(%rbp),%rax
lea    -0xfb0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xfb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb8(%rbp)
jmp    11af <main+0x7f>
lea    0xe0f(%rip),%rdi
lea    -0xfbc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xfbc(%rbp),%esi
sub    $0x1,%esi
mov    $0x2,%edi
call   1050 <pow@plt>
sub    $0x1,%eax
mov    %eax,-0xfc0(%rbp)
mov    -0xfc0(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0xfc4(%rbp)
cmpl   $0x1,-0xfbc(%rbp)
je     1259 <main+0x129>
mov    -0xfb4(%rbp),%eax
sub    -0xfc0(%rbp),%eax
cmp    $0x1,%eax
jne    127a <main+0x14a>
movslq -0xfc0(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1142 <main+0x12>
mov    -0xfc0(%rbp),%eax
cmp    -0xfb4(%rbp),%eax
jle    129f <main+0x16f>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1142 <main+0x12>
movslq -0xfc0(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c0 <main+0x190>
mov    -0xfc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb8(%rbp)
mov    -0xfb8(%rbp),%ecx
xor    %eax,%eax
cmp    -0xfc4(%rbp),%ecx
mov    %al,-0xfc5(%rbp)
jge    12fe <main+0x1ce>
mov    -0xfb8(%rbp),%eax
cmp    -0xfb4(%rbp),%eax
setl   %al
mov    %al,-0xfc5(%rbp)
mov    -0xfc5(%rbp),%al
test   $0x1,%al
jne    1311 <main+0x1e1>
jmp    1341 <main+0x211>
movslq -0xfb8(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xfb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb8(%rbp)
jmp    12cf <main+0x19f>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfb8,%rsp
lea    0xe8d(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x2e5f(%rip),%r13
cmp    0x0(%r13),%rax
jne    11a3 <main+0x43>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe5b(%rip),%r14
lea    0xe53(%rip),%r15
jmp    11e7 <main+0x87>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cltq
mov    0x10(%rsp,%rax,4),%esi
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
cmp    0x0(%r13),%rax
je     118f <main+0x2f>
mov    $0xfa4,%edx
lea    0x10(%rsp),%rdi
mov    $0xff,%esi
call   1060 <memset@plt>
cmpl   $0x0,0x8(%rsp)
jle    122d <main+0xcd>
lea    0x10(%rsp),%rbp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%rbx
jl     1210 <main+0xb0>
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    $0x2,%edi
call   1080 <pow@plt>
mov    %eax,%r12d
lea    -0x1(%r12),%eax
cmpl   $0x1,0xc(%rsp)
je     11c0 <main+0x60>
mov    0x8(%rsp),%ecx
mov    %ecx,%edx
sub    %eax,%edx
cmp    $0x1,%edx
je     11c0 <main+0x60>
cmp    %eax,%ecx
jge    1284 <main+0x124>
lea    0xd8e(%rip),%rdi
call   1040 <puts@plt>
jmp    11d4 <main+0x74>
mov    %r13,%rbx
lea    (%r12,%r12,1),%r13d
add    $0xffffffff,%r13d
cltq
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %r13d,%r12d
jge    12e4 <main+0x184>
cmp    0x8(%rsp),%r12d
jge    12e4 <main+0x184>
movslq %r12d,%rbp
movslq %r13d,%r12
add    $0x1,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    0xc(%rsp,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %r12,%rbp
jge    12e4 <main+0x184>
lea    0x1(%rbp),%rax
movslq 0x8(%rsp),%rcx
cmp    %rcx,%rbp
mov    %rax,%rbp
jl     12c0 <main+0x160>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%r13
jmp    11d4 <main+0x74>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [7 x i8] c"EMPTY\0A\00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1001 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
br label %8
8: ; preds = %93, %62, %52, %0
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %95
12: ; preds = %8
store i32 0, i32* %4
br label %13
13: ; preds = %20, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 1001
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 %18
store i32 -1, i32* %19
br label %20
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %13
23: ; preds = %13
store i32 0, i32* %4
br label %24
24: ; preds = %33, %23
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 %30
%32 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %31)
br label %33
33: ; preds = %28
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %24
36: ; preds = %24
%37 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%38 = load i32, i32* %5
%39 = sub nsw i32 %38, 1
%40 = call i32 @pow(i32 2, i32 %39)
%41 = sub nsw i32 %40, 1
store i32 %41, i32* %6
%42 = load i32, i32* %6
%43 = mul nsw i32 %42, 2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 1
br i1 %46, label %52, label %47
47: ; preds = %36
%48 = load i32, i32* %3
%49 = load i32, i32* %6
%50 = sub nsw i32 %48, %49
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %58
52: ; preds = %47, %36
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
br label %8
58: ; preds = %47
%59 = load i32, i32* %6
%60 = load i32, i32* %3
%61 = icmp sgt i32 %59, %60
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %8
64: ; preds = %58
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %64
br label %71
71: ; preds = %70
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %74
74: ; preds = %90, %71
%75 = load i32, i32* %4
%76 = load i32, i32* %7
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %82
78: ; preds = %74
%79 = load i32, i32* %4
%80 = load i32, i32* %3
%81 = icmp slt i32 %79, %80
br label %82
82: ; preds = %78, %74
%83 = phi i1 [ false, %74 ], [ %81, %78 ]
br i1 %83, label %84, label %93
84: ; preds = %82
%85 = load i32, i32* %4
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 %86
%88 = load i32, i32* %87
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %84
%91 = load i32, i32* %4
%92 = add nsw i32 %91, 1
store i32 %92, i32* %4
br label %74
93: ; preds = %82
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %8
95: ; preds = %8
ret i32 0
}

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