// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %r15
leal -0x1(%r14,%r14), %eax
movslq %eax, %rsi
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x28(%rsp), %rdi
movl $0x20, %edx
callq 0x2190
leal -0x1(,%r12,2), %eax
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0x356a
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x292b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2160
testl %r12d, %r12d
jle 0x2976
movl %r12d, %eax
movl %r14d, %ecx
xorl %edx, %edx
testl %r14d, %r14d
jle 0x296e
movq %rdx, %rsi
shlq $0x6, %rsi
movq %rdx, %rdi
shlq $0x5, %rdi
xorl %r8d, %r8d
movq (%r15), %r9
movq (%r9,%rdi), %r9
movb (%r9,%r8), %r9b
movq 0x10(%rsp), %r10
movq (%r10,%rsi), %r10
movb %r9b, (%r10,%r8,2)
incq %r8
cmpq %r8, %rcx
jne 0x294e
incq %rdx
cmpq %rax, %rdx
jne 0x2938
movq (%rbx), %r15
movq 0x8(%rbx), %r12
cmpq %r12, %r15
je 0x2acd
movq 0x6643(%rip), %rbx      # 0x8fd0
leaq 0x36cc(%rip), %r14      # 0x6060
movq 0x20(%r15), %rax
movq (%rax), %r13
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x2180
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2180
leal (,%r13,2), %eax
cltq
movq 0x10(%rsp), %rcx
shlq $0x5, %rax
shrq $0x1f, %r13
movslq %r13d, %r13
andq $-0x2, %r13
movq (%rcx,%rax), %rbp
movsbl (%rbp,%r13), %edi
callq 0x22a0
movb %al, (%rbp,%r13)
movq 0x28(%r15), %rax
subq 0x20(%r15), %rax
shrq $0x3, %rax
cmpl $0x2, %eax
jl 0x2ac0
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %ecx
movq 0x20(%r15), %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 0x2a54
cmpl %edx, %esi
jne 0x2a54
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 0x2ab4
subl %edx, %esi
movl %esi, %r10d
negl %r10d
cmovsl %esi, %r10d
cmpl %r8d, %r9d
jne 0x2a84
cmpl $0x1, %r10d
jne 0x2a84
movq 0x10(%rsp), %rdi
shlq $0x6, %r8
leal (%rsi,%rdx,2), %edx
movslq %edx, %rdx
movq (%rdi,%r8), %rsi
movb $0x2d, (%rsi,%rdx)
jmp 0x2ab4
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 0x2aaa
addl %edx, %edi
movslq %edi, %rdx
movb $0x5c, (%r8,%rdx)
jmp 0x2ab4
addl %edx, %esi
movslq %esi, %rdx
movb $0x2f, (%r8,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x2a0b
addq $0x38, %r15
cmpq %r12, %r15
jne 0x2994
movq 0x64fc(%rip), %rdi      # 0x8fd0
leaq 0x3587(%rip), %rsi      # 0x6062
movl $0x1, %edx
callq 0x2180
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r12, %r15
je 0x2b2a
movq 0x64d5(%rip), %rbx      # 0x8fd0
leaq 0x3560(%rip), %r14      # 0x6062
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x2180
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2180
addq $0x20, %r15
cmpq %r12, %r15
jne 0x2b02
leaq 0x10(%rsp), %rdi
callq 0x35fe
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b68
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x2b75
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2160
jmp 0x2b75
movq %rax, %rbx
jmp 0x2b75
jmp 0x2b68
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35fe
movq %rbx, %rdi
callq 0x2280