// File: 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 %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movl $0x0, -0x4(%rbp)
movb $0x1, -0x252(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x268(%rbp)
movq %rax, -0x128(%rbp)
movl $0x4, -0x140(%rbp)
movl $0x6, -0x13c(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x138(%rbp)
movq $0x2, -0x130(%rbp)
leaq -0x141(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x1c80
movq -0x268(%rbp), %rdi
movq -0x260(%rbp), %rcx
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
callq 0x1ca0
jmp 0x1411
leaq -0x108(%rbp), %rax
movq %rax, -0x278(%rbp)
movq %rax, -0x128(%rbp)
movl $0x6, -0x170(%rbp)
movl $0x8, -0x16c(%rbp)
leaq -0x170(%rbp), %rax
movq %rax, -0x168(%rbp)
movq $0x2, -0x160(%rbp)
leaq -0x171(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x1c80
movq -0x278(%rbp), %rdi
movq -0x270(%rbp), %rcx
movq -0x168(%rbp), %rsi
movq -0x160(%rbp), %rdx
callq 0x1ca0
jmp 0x1489
leaq -0xf0(%rbp), %rax
movq %rax, -0x288(%rbp)
movq %rax, -0x128(%rbp)
movl $0x7, -0x190(%rbp)
movl $0x9, -0x18c(%rbp)
leaq -0x190(%rbp), %rax
movq %rax, -0x188(%rbp)
movq $0x2, -0x180(%rbp)
leaq -0x191(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x1c80
movq -0x288(%rbp), %rdi
movq -0x280(%rbp), %rcx
movq -0x188(%rbp), %rsi
movq -0x180(%rbp), %rdx
callq 0x1ca0
jmp 0x1501
leaq -0xd8(%rbp), %rax
movq %rax, -0x298(%rbp)
movq %rax, -0x128(%rbp)
movl $0x4, -0x1b0(%rbp)
movl $0x8, -0x1ac(%rbp)
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq $0x2, -0x1a0(%rbp)
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x1c80
movq -0x298(%rbp), %rdi
movq -0x290(%rbp), %rcx
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
callq 0x1ca0
jmp 0x1579
leaq -0xc0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq %rax, -0x128(%rbp)
movl $0x0, -0x1d4(%rbp)
movl $0x3, -0x1d0(%rbp)
movl $0x9, -0x1cc(%rbp)
leaq -0x1d4(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq $0x3, -0x1c0(%rbp)
leaq -0x1d5(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x1c80
movq -0x2a8(%rbp), %rdi
movq -0x2a0(%rbp), %rcx
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
callq 0x1ca0
jmp 0x15fb
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x128(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, -0xa8(%rbp)
movq $0x0, -0x98(%rbp)
callq 0x1d20
leaq -0x90(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq %rax, -0x128(%rbp)
movl $0x0, -0x1f4(%rbp)
movl $0x1, -0x1f0(%rbp)
movl $0x7, -0x1ec(%rbp)
leaq -0x1f4(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq $0x3, -0x1e0(%rbp)
leaq -0x1f5(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x1c80
movq -0x2b8(%rbp), %rdi
movq -0x2b0(%rbp), %rcx
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rdx
callq 0x1ca0
jmp 0x16a5
leaq -0x78(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq %rax, -0x128(%rbp)
movl $0x2, -0x210(%rbp)
movl $0x6, -0x20c(%rbp)
leaq -0x210(%rbp), %rax
movq %rax, -0x208(%rbp)
movq $0x2, -0x200(%rbp)
leaq -0x211(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x1c80
movq -0x2c8(%rbp), %rdi
movq -0x2c0(%rbp), %rcx
movq -0x208(%rbp), %rsi
movq -0x200(%rbp), %rdx
callq 0x1ca0
jmp 0x171a
leaq -0x60(%rbp), %rax
movq %rax, -0x2d8(%rbp)
movq %rax, -0x128(%rbp)
movl $0x1, -0x230(%rbp)
movl $0x3, -0x22c(%rbp)
leaq -0x230(%rbp), %rax
movq %rax, -0x228(%rbp)
movq $0x2, -0x220(%rbp)
leaq -0x231(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x1c80
movq -0x2d8(%rbp), %rdi
movq -0x2d0(%rbp), %rcx
movq -0x228(%rbp), %rsi
movq -0x220(%rbp), %rdx
callq 0x1ca0
jmp 0x178f
leaq -0x48(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq %rax, -0x128(%rbp)
movl $0x2, -0x250(%rbp)
movl $0x4, -0x24c(%rbp)
leaq -0x250(%rbp), %rax
movq %rax, -0x248(%rbp)
movq $0x2, -0x240(%rbp)
leaq -0x251(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x1c80
movq -0x2e8(%rbp), %rdi
movq -0x2e0(%rbp), %rcx
movq -0x248(%rbp), %rsi
movq -0x240(%rbp), %rdx
callq 0x1ca0
jmp 0x1804
movb $0x0, -0x252(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0xa, -0x28(%rbp)
leaq -0x253(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x1d40
movq -0x2f0(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x1d60
jmp 0x184b
leaq -0x253(%rbp), %rdi
callq 0x1de0
leaq -0x120(%rbp), %rax
movq %rax, -0x300(%rbp)
addq $0xf0, %rax
movq %rax, -0x2f8(%rbp)
movq -0x2f8(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x308(%rbp)
callq 0x1e00
movq -0x300(%rbp), %rcx
movq -0x308(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2f8(%rbp)
jne 0x1872
leaq -0x251(%rbp), %rdi
callq 0x1e60
leaq -0x231(%rbp), %rdi
callq 0x1e60
leaq -0x211(%rbp), %rdi
callq 0x1e60
leaq -0x1f5(%rbp), %rdi
callq 0x1e60
leaq -0x1d5(%rbp), %rdi
callq 0x1e60
leaq -0x1b1(%rbp), %rdi
callq 0x1e60
leaq -0x191(%rbp), %rdi
callq 0x1e60
leaq -0x171(%rbp), %rdi
callq 0x1e60
leaq -0x141(%rbp), %rdi
callq 0x1e60
movl $0x0, -0x258(%rbp)
movq 0x56c0(%rip), %rdi      # 0x6fe0
leaq -0x258(%rbp), %rsi
callq 0x1030
jmp 0x192e
movl -0x258(%rbp), %ecx
leaq -0x20(%rbp), %rdi
movl $0x9, %esi
movl $0x1, %edx
callq 0x1270
movl %eax, -0x30c(%rbp)
jmp 0x194f
movl -0x30c(%rbp), %esi
movq 0x5674(%rip), %rdi      # 0x6fd0
callq 0x10d0
movq %rax, -0x318(%rbp)
jmp 0x196a
movq -0x318(%rbp), %rdi
movl $0xa, %esi
callq 0x10c0
jmp 0x197d
leaq -0x20(%rbp), %rdi
callq 0x1e80
movl -0x4(%rbp), %eax
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1b2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1b1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1b12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1b06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1aee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1ae2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1ad6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x1aca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x253(%rbp), %rdi
callq 0x1de0
leaq -0x120(%rbp), %rax
movq %rax, -0x328(%rbp)
addq $0xf0, %rax
movq %rax, -0x320(%rbp)
movq -0x320(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x330(%rbp)
callq 0x1e00
movq -0x328(%rbp), %rcx
movq -0x330(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x320(%rbp)
jne 0x1a97
jmp 0x1aca
leaq -0x251(%rbp), %rdi
callq 0x1e60
leaq -0x231(%rbp), %rdi
callq 0x1e60
leaq -0x211(%rbp), %rdi
callq 0x1e60
leaq -0x1f5(%rbp), %rdi
callq 0x1e60
leaq -0x1d5(%rbp), %rdi
callq 0x1e60
leaq -0x1b1(%rbp), %rdi
callq 0x1e60
leaq -0x191(%rbp), %rdi
callq 0x1e60
leaq -0x171(%rbp), %rdi
callq 0x1e60
leaq -0x141(%rbp), %rdi
callq 0x1e60
testb $0x1, -0x252(%rbp)
jne 0x1b41
jmp 0x1b8e
movq -0x128(%rbp), %rax
leaq -0x120(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x338(%rbp)
je 0x1b8c
movq -0x338(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x340(%rbp)
callq 0x1e00
movq -0x340(%rbp), %rax
leaq -0x120(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x338(%rbp)
jne 0x1b5b
jmp 0x1b8e
jmp 0x1bab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1e80
movq -0x150(%rbp), %rdi
callq 0x1120
nopw (%rax,%rax)