// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r12
leal -0x1(%rbx,%rbx), %eax
movslq %eax, %rsi
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x28(%rsp), %rdi
pushq $0x20
popq %rdx
callq 0x21b0
leal -0x1(,%r15,2), %eax
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0x31de
leaq 0x28(%rsp), %rdi
callq 0x20c0
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
testl %r15d, %r15d
cmovlel %eax, %r15d
cmpq %r15, %rax
je 0x283d
movq %rax, %rcx
shlq $0x6, %rcx
movq %rax, %rdx
shlq $0x5, %rdx
xorl %esi, %esi
cmpq %rsi, %rbx
je 0x2838
movq (%r12), %rdi
movq (%rdi,%rdx), %rdi
movb (%rdi,%rsi), %dil
movq 0x10(%rsp), %r8
movq (%r8,%rcx), %r8
movb %dil, (%r8,%rsi,2)
incq %rsi
jmp 0x2815
incq %rax
jmp 0x2800
movq (%r14), %rbx
movq 0x8(%r14), %r12
leaq 0x3815(%rip), %r15      # 0x6060
pushq $0x1
popq %r13
cmpq %r12, %rbx
je 0x297c
movq 0x20(%rbx), %rax
movq (%rax), %rbp
movq 0x7762(%rip), %rdi      # 0x9fc8
movq %rbx, %rsi
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
leal (,%rbp,2), %eax
cltq
movq 0x10(%rsp), %rcx
shlq $0x5, %rax
shrq $0x1f, %rbp
movslq %ebp, %rbp
andq $-0x2, %rbp
movq (%rcx,%rax), %r14
movsbl (%r14,%rbp), %edi
callq 0x22d0
movb %al, (%r14,%rbp)
movq 0x28(%rbx), %rax
subq 0x20(%rbx), %rax
shrq $0x3, %rax
cltq
movq %r13, %rcx
cmpq %rax, %rcx
jge 0x2973
movq 0x20(%rbx), %rsi
movslq -0x8(%rsi,%rcx,8), %r8
movl -0x4(%rsi,%rcx,8), %edx
movl (%rsi,%rcx,8), %r9d
movl 0x4(%rsi,%rcx,8), %esi
movl %r9d, %edi
subl %r8d, %edi
leal 0x1(%rdi), %r10d
testl $0xfffffffd, %r10d      # imm = 0xFFFFFFFD
jne 0x290b
cmpl %edx, %esi
jne 0x290b
movslq %edx, %rdx
leal (%rdi,%r8,2), %esi
movslq %esi, %rsi
movq 0x10(%rsp), %rdi
shlq $0x5, %rsi
movq (%rdi,%rsi), %rsi
movb $0x7c, (%rsi,%rdx,2)
jmp 0x296b
subl %edx, %esi
movl %esi, %r10d
negl %r10d
cmovsl %esi, %r10d
cmpl %r8d, %r9d
jne 0x293b
cmpl $0x1, %r10d
jne 0x293b
movq 0x10(%rsp), %rdi
shlq $0x6, %r8
leal (%rsi,%rdx,2), %edx
movslq %edx, %rdx
movq (%rdi,%r8), %rsi
movb $0x2d, (%rsi,%rdx)
jmp 0x296b
leal (%rdi,%r8,2), %r8d
movslq %r8d, %r8
shlq $0x5, %r8
addl %edx, %edx
movq 0x10(%rsp), %r9
movq (%r9,%r8), %r8
cmpl %esi, %edi
jne 0x2961
addl %edx, %edi
movslq %edi, %rdx
movb $0x5c, (%r8,%rdx)
jmp 0x296b
addl %edx, %esi
movslq %esi, %rdx
movb $0x2f, (%r8,%rdx)
incq %rcx
jmp 0x28b9
addq $0x38, %rbx
jmp 0x284f
movq 0x7645(%rip), %rdi      # 0x9fc8
leaq 0x36d8(%rip), %rsi      # 0x6062
callq 0x2180
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r12
movq 0x7628(%rip), %r14      # 0x9fc8
leaq 0x36bb(%rip), %r15      # 0x6062
cmpq %r12, %rbx
je 0x29c8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
addq $0x20, %rbx
jmp 0x29a7
leaq 0x10(%rsp), %rdi
callq 0x3234
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29f9
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x20c0
jmp 0x2a06
movq %rax, %rbx
jmp 0x2a06
jmp 0x29f9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3234
movq %rbx, %rdi
callq 0x22b0