// File: /workspace/github_cpp_makefile_star2_O1/kdungs[P]codecon/src/maze.cc
// Function: main
int main() {
  auto rows = 0ul, cols = 0ul;
  std::cin >> rows >> cols;

  if (rows < 2 || cols < 2) {
    return EXIT_FAILURE;
  }

  auto map = std::vector<bool>{};
  map.reserve(rows * cols);
  char in;
  while (std::cin >> in) {
    map.push_back((in == '_'));
  }

  auto maze = Maze{rows, cols, map};
  auto path = solveBfs(maze, {1, 0}, {rows - 2, cols - 1});

  std::copy(std::begin(path), std::end(path),
            std::ostream_iterator<Point>(std::cout, "\n"));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xc0, %rsp
xorl %eax, %eax
leaq 0x48(%rsp), %rbx
movq %rax, (%rbx)
leaq 0x40(%rsp), %r14
movq %rax, (%r14)
movq 0x3675(%rip), %rdi      # 0x4fe0
movq %rbx, %rsi
callq 0x1080
movq %rax, %rdi
movq %r14, %rsi
callq 0x1080
movq (%rbx), %rcx
cmpq $0x2, %rcx
setb %al
movq (%r14), %rsi
cmpq $0x2, %rsi
setb %dl
orb %al, %dl
movl $0x1, %eax
jne 0x1b44
imulq %rcx, %rsi
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
movq $0x0, 0x20(%rdi)
callq 0x1d60
movq 0x361a(%rip), %rbx      # 0x4fe0
leaq 0xf(%rsp), %r14
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1100
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x19fe
xorl %esi, %esi
cmpb $0x5f, 0xf(%rsp)
sete %sil
movq %r15, %rdi
callq 0x1d92
jmp 0x19d0
movq 0x48(%rsp), %rax
leaq 0x78(%rsp), %rdi
movq %rax, -0x10(%rdi)
movq 0x40(%rsp), %rax
movq %rax, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
callq 0x1de0
leaq 0xa0(%rsp), %rdx
movq $0x1, (%rdx)
movq $0x0, 0x8(%rdx)
movq 0x48(%rsp), %rax
addq $-0x2, %rax
leaq 0xb0(%rsp), %rcx
movq %rax, (%rcx)
movq 0x40(%rsp), %rax
decq %rax
movq %rax, 0x8(%rcx)
leaq 0x50(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x12ca
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %r15
movq 0x355a(%rip), %rax      # 0x4fd0
movq %rax, 0xa0(%rsp)
leaq 0x157f(%rip), %rax      # 0x3004
movq %rax, 0xa8(%rsp)
subq %rbx, %r15
sarq $0x4, %r15
testq %r15, %r15
jle 0x1abc
incq %r15
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x263c
addq $0x10, %rbx
decq %r15
cmpq $0x1, %r15
jg 0x1aa4
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1ad3
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x1b12
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
movq %rax, 0x78(%rsp)
movl %eax, 0x80(%rsp)
movq %rax, 0x88(%rsp)
movl %eax, 0x90(%rsp)
movq %rax, 0x98(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1b42
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movq %rax, 0x30(%rsp)
xorl %eax, %eax
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0x1b74
jmp 0x1bb5
jmp 0x1bb5
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1b74
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x1bb8
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
movq %rax, 0x78(%rsp)
movl %eax, 0x80(%rsp)
movq %rax, 0x88(%rsp)
movl %eax, 0x90(%rsp)
movq %rax, 0x98(%rsp)
jmp 0x1bb8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1be8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
callq 0x1130