// File: razimantv[P]DancingLinks/spangram/spangram.cpp
// Function: print_solution(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, int, int, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>>>> const&)
void print_solution(const std::vector<std::string>& grid, int m, int n,
                    const std::vector<Placement>& placements) {
  // Output grid with spaces between characters to put paths
  std::vector<std::string> output(2 * m - 1, std::string(2 * n - 1, ' '));

  // Fill the output grid with the characters from the input grid
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) output[2 * i][2 * j] = grid[i][j];

  // Process paths and output the words
  for (const auto& [word, path] : placements) {
    // Capitalise the first letter of the word
    auto [x, y] = path[0];
    std::cout << word << " ";
    output[2 * x][2 * y] = toupper(output[2 * x][2 * y]);

    // Draw the path on the output grid
    for (int i = 1, l = path.size(); i < l; i++) {
      int x1 = path[i - 1].first, y1 = path[i - 1].second, x2 = path[i].first,
          y2 = path[i].second, dx = x2 - x1, dy = y2 - y1;
      if (abs(dx) == 1 and dy == 0) {
        output[2 * x1 + dx][2 * y1] = '|';
      } else if (abs(dy) == 1 and dx == 0) {
        output[2 * x1][2 * y1 + dy] = '-';
      } else if (dx == dy) {
        output[2 * x1 + dx][2 * y1 + dy] = '\\';
      } else {
        output[2 * x1 + dx][2 * y1 + dy] = '/';
      }
    }
  }
  std::cout << "\n";

  // Print the output grid
  for (const auto& line : output) std::cout << line << "\n";
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x170(%rsp)
movl %esi, 0x16c(%rsp)
movl %edx, 0x168(%rsp)
movq %rcx, 0x160(%rsp)
movl 0x16c(%rsp), %ecx
movl %ecx, %eax
leal -0x1(%rax,%rax), %eax
cltq
movq %rax, 0x68(%rsp)
movl 0x168(%rsp), %ecx
movl %ecx, %eax
leal -0x1(%rax,%rax), %eax
cltq
movq %rax, 0x70(%rsp)
leaq 0x127(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x3400
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
leaq 0x128(%rsp), %rdi
movl $0x20, %edx
callq 0x5ad0
jmp 0x3f0d
leaq 0x113(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x5b50
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rcx
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x5b60
jmp 0x3f40
leaq 0x113(%rsp), %rdi
callq 0x5be0
leaq 0x128(%rsp), %rdi
callq 0x3160
leaq 0x127(%rsp), %rdi
callq 0x3290
movl $0x0, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
cmpl 0x16c(%rsp), %eax
jge 0x40b9
movl $0x0, 0x108(%rsp)
movl 0x108(%rsp), %eax
cmpl 0x168(%rsp), %eax
jge 0x40a1
movq 0x170(%rsp), %rdi
movslq 0x10c(%rsp), %rsi
callq 0x57c0
movq %rax, %rdi
movslq 0x108(%rsp), %rsi
callq 0x32b0
movb (%rax), %al
movb %al, 0x57(%rsp)
movl 0x10c(%rsp), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq %rax, %rdi
movl 0x108(%rsp), %eax
addl %eax, %eax
movslq %eax, %rsi
callq 0x3460
movq %rax, 0x58(%rsp)
jmp 0x4004
movq 0x58(%rsp), %rax
movb 0x57(%rsp), %cl
movb %cl, (%rax)
movl 0x108(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x108(%rsp)
jmp 0x3f91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0x4069
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0x113(%rsp), %rdi
callq 0x5be0
leaq 0x128(%rsp), %rdi
callq 0x3160
leaq 0x127(%rsp), %rdi
callq 0x3290
jmp 0x45c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x5df0
jmp 0x45c6
jmp 0x40a3
movl 0x10c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10c(%rsp)
jmp 0x3f72
movq 0x160(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rdi
callq 0x5c10
movq %rax, 0xf8(%rsp)
movq 0x100(%rsp), %rdi
callq 0x5c40
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x5c70
testb $0x1, %al
jne 0x4111
jmp 0x44f5
leaq 0xf8(%rsp), %rdi
callq 0x5cb0
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x5cc0
movq %rax, 0xe0(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x5cd0
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x56f0
movq (%rax), %rax
movq %rax, 0xd0(%rsp)
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x5ce0
movq 0x40(%rsp), %rdi
movq %rax, 0xc8(%rsp)
callq 0x5cf0
movq %rax, 0xc0(%rsp)
movq 0xe0(%rsp), %rsi
movq 0x13e21(%rip), %rdi     # 0x17fc8
callq 0x3220
movq %rax, 0x48(%rsp)
jmp 0x41b3
movq 0x48(%rsp), %rdi
leaq 0xce49(%rip), %rsi      # 0x11008
callq 0x3250
jmp 0x41c6
movq 0xc8(%rsp), %rax
movl (%rax), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq %rax, %rdi
movq 0xc0(%rsp), %rax
movl (%rax), %eax
addl %eax, %eax
movslq %eax, %rsi
callq 0x3460
movq %rax, 0x38(%rsp)
jmp 0x4200
movq 0x38(%rsp), %rax
movsbl (%rax), %edi
callq 0x3420
movb %al, 0x2f(%rsp)
movq 0xc8(%rsp), %rax
movl (%rax), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq %rax, %rdi
movq 0xc0(%rsp), %rax
movl (%rax), %eax
addl %eax, %eax
movslq %eax, %rsi
callq 0x3460
movq %rax, 0x30(%rsp)
jmp 0x424b
movq 0x30(%rsp), %rax
movb 0x2f(%rsp), %cl
movb %cl, (%rax)
movl $0x1, 0xbc(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x5690
movl %eax, 0xb8(%rsp)
movl 0xbc(%rsp), %eax
cmpl 0xb8(%rsp), %eax
jge 0x44e1
movq 0xd8(%rsp), %rdi
movl 0xbc(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x56f0
movl (%rax), %eax
movl %eax, 0xb4(%rsp)
movq 0xd8(%rsp), %rdi
movl 0xbc(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x56f0
movl 0x4(%rax), %eax
movl %eax, 0xb0(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xbc(%rsp), %rsi
callq 0x56f0
movl (%rax), %eax
movl %eax, 0xac(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xbc(%rsp), %rsi
callq 0x56f0
movl 0x4(%rax), %eax
movl %eax, 0xa8(%rsp)
movl 0xac(%rsp), %eax
subl 0xb4(%rsp), %eax
movl %eax, 0xa4(%rsp)
movl 0xa8(%rsp), %eax
subl 0xb0(%rsp), %eax
movl %eax, 0xa0(%rsp)
movl 0xa4(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl $0x1, %eax
jne 0x43a1
cmpl $0x0, 0xa0(%rsp)
jne 0x43a1
movl 0xb4(%rsp), %eax
movl 0xa4(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movslq %eax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq %rax, %rdi
movl 0xb0(%rsp), %eax
addl %eax, %eax
movslq %eax, %rsi
callq 0x3460
movq %rax, 0x20(%rsp)
jmp 0x4394
movq 0x20(%rsp), %rax
movb $0x7c, (%rax)
jmp 0x44c9
movl 0xa0(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl $0x1, %eax
jne 0x440b
cmpl $0x0, 0xa4(%rsp)
jne 0x440b
movl 0xb4(%rsp), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq %rax, %rdi
movl 0xb0(%rsp), %eax
movl 0xa0(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movslq %eax, %rsi
callq 0x3460
movq %rax, 0x18(%rsp)
jmp 0x43fe
movq 0x18(%rsp), %rax
movb $0x2d, (%rax)
jmp 0x44c7
movl 0xa4(%rsp), %eax
cmpl 0xa0(%rsp), %eax
jne 0x4471
movl 0xb4(%rsp), %eax
movl 0xa4(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movslq %eax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq %rax, %rdi
movl 0xb0(%rsp), %eax
movl 0xa0(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movslq %eax, %rsi
callq 0x3460
movq %rax, 0x10(%rsp)
jmp 0x4467
movq 0x10(%rsp), %rax
movb $0x5c, (%rax)
jmp 0x44c5
movl 0xb4(%rsp), %eax
movl 0xa4(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movslq %eax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq %rax, %rdi
movl 0xb0(%rsp), %eax
movl 0xa0(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movslq %eax, %rsi
callq 0x3460
movq %rax, 0x8(%rsp)
jmp 0x44bd
movq 0x8(%rsp), %rax
movb $0x2f, (%rax)
jmp 0x44c7
jmp 0x44c9
jmp 0x44cb
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0x4275
jmp 0x44e3
leaq 0xf8(%rsp), %rdi
callq 0x5d00
jmp 0x40f3
movq 0x13acc(%rip), %rdi     # 0x17fc8
leaq 0xcb28(%rip), %rsi      # 0x1102b
callq 0x3250
jmp 0x450a
leaq 0x148(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
callq 0x5d20
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rdi
callq 0x5d50
movq %rax, 0x88(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x5d80
testb $0x1, %al
jne 0x455f
jmp 0x45b1
leaq 0x90(%rsp), %rdi
callq 0x5dc0
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rsi
movq 0x13a45(%rip), %rdi     # 0x17fc8
callq 0x3220
movq %rax, (%rsp)
jmp 0x458e
movq (%rsp), %rdi
leaq 0xca92(%rip), %rsi      # 0x1102b
callq 0x3250
jmp 0x45a0
jmp 0x45a2
leaq 0x90(%rsp), %rdi
callq 0x5dd0
jmp 0x4544
leaq 0x148(%rsp), %rdi
callq 0x5df0
addq $0x178, %rsp            # imm = 0x178
retq
movq 0x118(%rsp), %rdi
callq 0x33f0
nopw %cs:(%rax,%rax)