#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int a;
  scanf("%i", &a);
  switch (a) {
  case 1:
    puts("1");
    break;
  case 2:
    puts("1 2\n"
         "3 4");
    break;
  case 3:
    puts("1 2 6\n"
         "3 5 7\n"
         "4 8 9");
    break;
  case 4:
    puts("1 2 6 7\n"
         "3 5 8 13\n"
         "4 9 12 14\n"
         "10 11 15 16");
    break;
  case 5:
    puts("1 2 6 7 15\n"
         "3 5 8 14 16\n"
         "4 9 13 17 22\n"
         "10 12 18 21 23\n"
         "11 19 20 24 25");
    break;
  case 6:
    puts("1 2 6 7 15 16\n"
         "3 5 8 14 17 26\n"
         "4 9 13 18 25 27\n"
         "10 12 19 24 28 33\n"
         "11 20 23 29 32 34\n"
         "21 22 30 31 35 36");
    break;
  case 7:
    puts("1 2 6 7 15 16 28\n"
         "3 5 8 14 17 27 29\n"
         "4 9 13 18 26 30 39\n"
         "10 12 19 25 31 38 40\n"
         "11 20 24 32 37 41 46\n"
         "21 23 33 36 42 45 47\n"
         "22 34 35 43 44 48 49");
    break;
  case 8:
    puts("1 2 6 7 15 16 28\n"
         "3 5 8 14 17 27 29\n"
         "4 9 13 18 26 30 39\n"
         "10 12 19 25 31 38 40\n"
         "11 20 24 32 37 41 46\n"
         "21 23 33 36 42 45 47\n"
         "22 34 35 43 44 48 49");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xee3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x7,%eax
ja     11f2 <main+0xd2>
mov    -0x20(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xd2>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xd2>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xd2>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xd2>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xd2>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xd2>
lea    0xf2f(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xd2>
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x7,%eax
ja     1153 <main+0x33>
cltq
lea    0x1031(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [8 x i8] c"1 2\0A3 4\00"
@.str.3 = [18 x i8] c"1 2 6\0A3 5 7\0A4 8 9\00"
@.str.4 = [39 x i8] c"1 2 6 7\0A3 5 8 13\0A4 9 12 14\0A10 11 15 16\00"
@.str.5 = [66 x i8] c"1 2 6 7 15\0A3 5 8 14 16\0A4 9 13 17 22\0A10 12 18 21 23\0A11 19 20 24 25\00"
@.str.6 = [99 x i8] c"1 2 6 7 15 16\0A3 5 8 14 17 26\0A4 9 13 18 25 27\0A10 12 19 24 28 33\0A11 20 23 29 32 34\0A21 22 30 31 35 36\00"
@.str.7 = [138 x i8] c"1 2 6 7 15 16 28\0A3 5 8 14 17 27 29\0A4 9 13 18 26 30 39\0A10 12 19 25 31 38 40\0A11 20 24 32 37 41 46\0A21 23 33 36 42 45 47\0A22 34 35 43 44 48 49\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%8 = load i32, i32* %6
switch i32 %8, label %25 [
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %15
i32 5, label %17
i32 6, label %19
i32 7, label %21
i32 8, label %23
]
9: ; preds = %2
%10 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %25
13: ; preds = %2
%14 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %25
15: ; preds = %2
%16 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %25
17: ; preds = %2
%18 = call i32 @puts(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0))
br label %25
19: ; preds = %2
%20 = call i32 @puts(i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.6, i64 0, i64 0))
br label %25
21: ; preds = %2
%22 = call i32 @puts(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.7, i64 0, i64 0))
br label %25
23: ; preds = %2
%24 = call i32 @puts(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.7, i64 0, i64 0))
br label %25
25: ; preds = %2, %23, %21, %19, %17, %15, %13, %11, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [8 x i8] c"1 2\0A3 4\00"
@.str.3 = [18 x i8] c"1 2 6\0A3 5 7\0A4 8 9\00"
@.str.4 = [39 x i8] c"1 2 6 7\0A3 5 8 13\0A4 9 12 14\0A10 11 15 16\00"
@.str.5 = [66 x i8] c"1 2 6 7 15\0A3 5 8 14 16\0A4 9 13 17 22\0A10 12 18 21 23\0A11 19 20 24 25\00"
@.str.6 = [99 x i8] c"1 2 6 7 15 16\0A3 5 8 14 17 26\0A4 9 13 18 25 27\0A10 12 19 24 28 33\0A11 20 23 29 32 34\0A21 22 30 31 35 36\00"
@.str.7 = [138 x i8] c"1 2 6 7 15 16 28\0A3 5 8 14 17 27 29\0A4 9 13 18 26 30 39\0A10 12 19 25 31 38 40\0A11 20 24 32 37 41 46\0A21 23 33 36 42 45 47\0A22 34 35 43 44 48 49\00"
@reltable.main = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([66 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([99 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([138 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([138 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = add i32 %6, -1
%8 = icmp ult i32 %7, 8
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = sext i32 %7 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.main to i8*), i64 %11)
%13 = call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %2, %9
ret i32 0
}