// File: /workspace/github_cpp_makefile_star2_O1/kdungs[P]codecon/src/golf.cc
// Function: main
int main() {
  const auto map = std::vector<std::vector<unsigned>>{{4, 6},
                                                      {6, 8},
                                                      {7, 9},
                                                      {4, 8},
                                                      {0, 3, 9},
                                                      {},
                                                      {0, 1, 7},
                                                      {2, 6},
                                                      {1, 3},
                                                      {2, 4}};

  auto steps = 0u;
  std::cin >> steps;

  std::cout << solve(map, 9u, 1u, steps) << '\n';
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x170, %rsp            # imm = 0x170
movabsq $0x600000004, %rax      # imm = 0x600000004
leaq 0x6c(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x80(%rsp), %r14
leaq 0x17(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x1614
leaq 0x98(%rsp), %rbx
movabsq $0x800000006, %rax      # imm = 0x800000006
leaq 0x64(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x16(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0xb0(%rsp), %rbx
movabsq $0x900000007, %rax      # imm = 0x900000007
leaq 0x5c(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x15(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0xc8(%rsp), %rbx
movabsq $0x800000004, %rax      # imm = 0x800000004
leaq 0x54(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x14(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0xe0(%rsp), %rbx
movabsq $0x300000000, %rax      # imm = 0x300000000
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl $0x9, 0x8(%rsi)
leaq 0x13(%rsp), %rcx
movl $0x3, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0x110(%rsp), %rbx
xorps %xmm0, %xmm0
movups %xmm0, -0x18(%rbx)
movq $0x0, -0x8(%rbx)
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq 0x74(%rsp), %rsi
movq %rax, (%rsi)
movl $0x7, 0x8(%rsi)
leaq 0x12(%rsp), %rcx
movl $0x3, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0x128(%rsp), %rbx
movabsq $0x600000002, %rax      # imm = 0x600000002
leaq 0x4c(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x11(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0x140(%rsp), %rbx
movabsq $0x300000001, %rax      # imm = 0x300000001
leaq 0x44(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x10(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0x158(%rsp), %rbx
movabsq $0x400000002, %rax      # imm = 0x400000002
leaq 0x3c(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x1614
leaq 0x18(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0xe(%rsp), %rcx
movl $0xa, %edx
callq 0x165a
movl $0xf0, %ebx
movq 0x68(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x1519
movq 0x78(%rsp,%rbx), %rsi
subq %rdi, %rsi
callq 0x10b0
addq $-0x18, %rbx
jne 0x1502
leaq 0x80(%rsp), %rsi
movl $0x0, (%rsi)
movq 0x2aac(%rip), %rdi      # 0x3fe0
callq 0x1110
movl 0x80(%rsp), %ecx
leaq 0x18(%rsp), %rdi
movl $0x9, %esi
movl $0x1, %edx
callq 0x12bc
movl %eax, %esi
movq 0x2a73(%rip), %rdi      # 0x3fd0
callq 0x1070
leaq 0x30(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x10c0
leaq 0x18(%rsp), %rdi
callq 0x16a4
xorl %eax, %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r15
leaq 0x170(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1140
movb $0x1, %al
jmp 0x15bf
jmp 0x15ba
jmp 0x15ba
jmp 0x15ba
jmp 0x15ba
jmp 0x15ba
jmp 0x15ba
jmp 0x15ba
movq %rax, %r15
xorl %eax, %eax
cmpq %rbx, %r14
sete %cl
testb %al, %al
jne 0x160c
testb %cl, %cl
jne 0x160c
leaq 0x80(%rsp), %r14
movq -0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x15ea
movq -0x8(%rbx), %rsi
subq %rdi, %rsi
callq 0x10b0
addq $-0x18, %rbx
cmpq %r14, %rbx
jne 0x15d5
jmp 0x160c
movq %rax, %r15
xorl %eax, %eax
movq %r14, %rbx
jmp 0x15bf
movq %rax, %r15
leaq 0x18(%rsp), %rdi
callq 0x16a4
movq %r15, %rdi
callq 0x1120