// File: /workspace/github_cpp_makefile_star2_O3/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), %rbx
leaq 0x17(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x1608
leaq 0x98(%rsp), %r14
movabsq $0x800000006, %rax      # imm = 0x800000006
leaq 0x64(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x16(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x1608
leaq 0xb0(%rsp), %r14
movabsq $0x900000007, %rax      # imm = 0x900000007
leaq 0x5c(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x15(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x1608
leaq 0xc8(%rsp), %r14
movabsq $0x800000004, %rax      # imm = 0x800000004
leaq 0x54(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x14(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x1608
leaq 0xe0(%rsp), %r14
movabsq $0x300000000, %rax      # imm = 0x300000000
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl $0x9, 0x8(%rsi)
leaq 0x13(%rsp), %rcx
movl $0x3, %edx
movq %r14, %rdi
callq 0x1608
leaq 0x110(%rsp), %r14
xorps %xmm0, %xmm0
movups %xmm0, -0x18(%r14)
movq $0x0, -0x8(%r14)
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq 0x74(%rsp), %rsi
movq %rax, (%rsi)
movl $0x7, 0x8(%rsi)
leaq 0x12(%rsp), %rcx
movl $0x3, %edx
movq %r14, %rdi
callq 0x1608
leaq 0x128(%rsp), %r14
movabsq $0x600000002, %rax      # imm = 0x600000002
leaq 0x4c(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x11(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x1608
leaq 0x140(%rsp), %r14
movabsq $0x300000001, %rax      # imm = 0x300000001
leaq 0x44(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x10(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x1608
leaq 0x158(%rsp), %r14
movabsq $0x400000002, %rax      # imm = 0x400000002
leaq 0x3c(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x1608
leaq 0x18(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0xe(%rsp), %rcx
movl $0xa, %edx
callq 0x164e
movl $0xf0, %ebx
movq 0x68(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x151a
movq 0x78(%rsp,%rbx), %rsi
subq %rdi, %rsi
callq 0x10b0
addq $-0x18, %rbx
jne 0x1503
leaq 0x80(%rsp), %rsi
movl $0x0, (%rsi)
movq 0x2aab(%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 0x2a72(%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 0x1698
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 0x15c0
jmp 0x15bb
jmp 0x15bb
jmp 0x15bb
jmp 0x15bb
jmp 0x15bb
jmp 0x15bb
jmp 0x15bb
movq %rax, %r15
xorl %eax, %eax
cmpq %r14, %rbx
sete %cl
testb %al, %al
jne 0x1600
testb %cl, %cl
jne 0x1600
movq -0x18(%r14), %rdi
testq %rdi, %rdi
je 0x15e3
movq -0x8(%r14), %rsi
subq %rdi, %rsi
callq 0x10b0
addq $-0x18, %r14
cmpq %rbx, %r14
jne 0x15ce
jmp 0x1600
movq %rax, %r15
jmp 0x1600
movq %rax, %r15
leaq 0x18(%rsp), %rdi
callq 0x1698
movq %r15, %rdi
callq 0x1120