// File: /workspace/github_cpp_makefile_star2_O1/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 0x3584
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x2927
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2160
testl %r12d, %r12d
jle 0x2972
movl %r12d, %eax
movl %r14d, %ecx
xorl %edx, %edx
testl %r14d, %r14d
jle 0x296a
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 0x294a
incq %rdx
cmpq %rax, %rdx
jne 0x2934
movq (%rbx), %r15
movq 0x8(%rbx), %r12
cmpq %r12, %r15
je 0x2ac2
movq 0x6647(%rip), %rbx      # 0x8fd0
leaq 0x36d0(%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 0x2ab5
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %ecx
movq 0x20(%r15), %rsi
movslq -0x8(%rsi,%rcx,8), %rdi
movl -0x4(%rsi,%rcx,8), %edx
movl (%rsi,%rcx,8), %r9d
movl 0x4(%rsi,%rcx,8), %esi
movl %r9d, %r8d
subl %edi, %r8d
leal 0x1(%r8), %r10d
testl $0xfffffffd, %r10d      # imm = 0xFFFFFFFD
jne 0x2a50
cmpl %edx, %esi
jne 0x2a50
movslq %edx, %rdx
leal (%r8,%rdi,2), %esi
movslq %esi, %rsi
movq 0x10(%rsp), %rdi
shlq $0x5, %rsi
movq (%rdi,%rsi), %rsi
movb $0x7c, (%rsi,%rdx,2)
jmp 0x2aa9
subl %edx, %esi
movl %esi, %r10d
negl %r10d
cmovsl %esi, %r10d
cmpl %edi, %r9d
jne 0x2a80
cmpl $0x1, %r10d
jne 0x2a80
movq 0x10(%rsp), %r8
shlq $0x6, %rdi
leal (%rsi,%rdx,2), %edx
movslq %edx, %rdx
movq (%r8,%rdi), %rsi
movb $0x2d, (%rsi,%rdx)
jmp 0x2aa9
leal (%r8,%rdi,2), %edi
movslq %edi, %rdi
shlq $0x5, %rdi
movq 0x10(%rsp), %r9
movq (%r9,%rdi), %rdi
leal (%rsi,%rdx,2), %edx
movslq %edx, %rdx
cmpl %esi, %r8d
jne 0x2aa5
movb $0x5c, (%rdi,%rdx)
jmp 0x2aa9
movb $0x2f, (%rdi,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x2a07
addq $0x38, %r15
cmpq %r12, %r15
jne 0x2990
movq 0x6507(%rip), %rdi      # 0x8fd0
leaq 0x3592(%rip), %rsi      # 0x6062
movl $0x1, %edx
callq 0x2180
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r12, %r15
je 0x2b1f
movq 0x64e0(%rip), %rbx      # 0x8fd0
leaq 0x356b(%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 0x2af7
leaq 0x10(%rsp), %rdi
callq 0x3618
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b5d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x2b6a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2160
jmp 0x2b6a
movq %rax, %rbx
jmp 0x2b6a
jmp 0x2b5d
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3618
movq %rbx, %rdi
callq 0x2280