Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Day 10

Day10.livemd

Day 10

Mix.install([
  {:kino_aoc, "~> 0.1.5"}
])

Day 10: Pipe Maze

You use the hang glider to ride the hot air from Desert Island all the way up to the floating metal island. This island is surprisingly cold and there definitely aren’t any thermals to glide on, so you leave your hang glider behind.

You wander around for a while, but you don’t find any people or animals. However, you do occasionally find signposts labeled “Hot Springs” pointing in a seemingly consistent direction; maybe you can find someone at the hot springs and ask them where the desert-machine parts are made.

The landscape here is alien; even the flowers and trees are made of metal. As you stop to admire some metal grass, you notice something metallic scurry away in your peripheral vision and jump into a big pipe! It didn’t look like any animal you’ve ever seen; if you want a better look, you’ll need to get ahead of it.

Scanning the area, you discover that the entire field you’re standing on is densely packed with pipes; it was hard to tell at first because they’re the same metallic silver color as the “ground”. You make a quick sketch of all of the surface pipes you can see (your puzzle input).

The pipes are arranged in a two-dimensional grid of tiles:

  • | is a vertical pipe connecting north and south.
  • - is a horizontal pipe connecting east and west.
  • L is a 90-degree bend connecting north and east.
  • J is a 90-degree bend connecting north and west.
  • 7 is a 90-degree bend connecting south and west.
  • F is a 90-degree bend connecting south and east.
  • . is ground; there is no pipe in this tile.
  • S is the starting position of the animal; there is a pipe on this tile, but your sketch doesn’t show what shape the pipe has.

Based on the acoustics of the animal’s scurrying, you’re confident the pipe that contains the animal is one large, continuous loop.

For example, here is a square loop of pipe:

.....
.F-7.
.|.|.
.L-J.
.....

If the animal had entered this loop in the northwest corner, the sketch would instead look like this:

.....
.S-7.
.|.|.
.L-J.
.....

In the above diagram, the S tile is still a 90-degree F bend: you can tell because of how the adjacent pipes connect to it.

Unfortunately, there are also many pipes that aren’t connected to the loop! This sketch shows the same loop as above:

-L|F7
7S-7|
L|7||
-L-J|
L|-JF

In the above diagram, you can still figure out which pipes form the main loop: they’re the ones connected to S, pipes those pipes connect to, pipes those pipes connect to, and so on. Every pipe in the main loop connects to its two neighbors (including S, which will have exactly two pipes connecting to it, and which is assumed to connect back to those two pipes).

Here is a sketch that contains a slightly more complex main loop:

..F7.
.FJ|.
SJ.L7
|F--J
LJ...

Here’s the same example sketch with the extra, non-main-loop pipe tiles also shown:

7-F7-
.FJ|7
SJLL7
|F--J
LJ.LJ

If you want to get out ahead of the animal, you should find the tile in the loop that is farthest from the starting position. Because the animal is in the pipe, it doesn’t make sense to measure this by direct distance. Instead, you need to find the tile that would take the longest number of steps along the loop to reach from the starting point - regardless of which way around the loop the animal went.

In the first example with the square loop:

.....
.S-7.
.|.|.
.L-J.
.....

You can count the distance each tile in the loop is from the starting point like this:

.....
.012.
.1.3.
.234.
.....

In this example, the farthest point from the start is 4 steps away.

Here’s the more complex loop again:

..F7.
.FJ|.
SJ.L7
|F--J
LJ...

Here are the distances for each tile on that loop:

..45.
.236.
01.78
14567
23...

Find the single giant loop starting at S. How many steps along the loop does it take to get from the starting position to the point farthest from the starting position?

{:ok, puzzle_input} =
  KinoAOC.download_puzzle("2023", "10", System.fetch_env!("LB_AOC_SESSION"))
{:ok,
 "F7F.7-7FF77|7.|-7-7-.|7F-7-|7-.|-FJ-.L7-J.F7..F---F-7-FF777.L7.FJ---.FFF|--7F-JF--.|J-|F-.LL7FFF7-JFJ--F-7L|7.J-L7FF-F7F|7-FFL7-L.--J77--F|7\n|-L.|L|--JLL7FLFL.|-J||J||-L7..F-|.LFJL7|7L|-JJ...L--F7|L7FFJ---|J-L7-JJ|.LL|.|-L.L7|.||-7|.|L7J7F-J.7-JL|JL7FJ|.J7-LL-7|LFL|L-7L-F-FJLL-||J\n-.LFL-JF|-|.L7F|...F7JL-J|-LL-FL7L7F7|.-J-FJ-7JF|.F-||||FJF77F|7F-7||-7F-..|.FJ|.F7LL--7.7-7|77L|7-7LF77FJF-.|.F|LJ-7.L.7FFF|-L7..J.JL77..LF\n|LJL|7FF|FJ.JJ7|F77F7-F7LJ..L7LF--JFF-7.LLF7LJ.-LFF--JLJL7|L7-F-FJ-|LFL7FJF7-JJ7L.F7|..|FJFLLLF7-JL7JL7-L77.F-J7JF||LJFFL|F-J--L-7JFJL-7-|7|\n7.FFJ|FL.L.LLLF7.FF.J-7J7.FL-L7-L.F-J||FF.|J|L-.LFL----7FJ|FJJJ-L-7|L|--|J7F77J|..F|-.FJJ--..L7LJ7.|7JL7L|7-|7L7-L-7LJ7LLLJJ|.LJLF77-F-|L-77\n|7-LF-J.FL|.7-LJF-JFL7|.|7J7LL-J-77.F|-7LF-.F|JFFLJJJF-JL-JL7J.LLL|F-FJ-|||LJJ-LF7J|JL-J|J--J-|.|F|-F77LJLJ-LJ-7-J|.-LJF-.J.FJ.|FLL7--7JLL|J\nLJ..LF7-FJ|-L--7LJF7.LJF||JF7.J77||FFJ||7.|--J.LLJLL|L-7F7F-J77F7LLL7|LF|7|F|JF||J.F77FFF-7|J.|.F7F77-JL7-|J.JJJ|F-7|7FL.F..---7.|.7J.LL7.|L\nL-7-LL|L|.|.|.LL.FJ7-JLF-77-J-JLF7LFF-FLF-7.|LFJLFFF7F7||||F7.FLL7J|L--7L7-7-.FL-7-|L7FF|FJJ.F7F|LJL77.F|.|7FL-F77-7J-JJF|--J.|FL-J|FF-.-F7|\n||L-JLJ7J|.|77.L7.L--J-|J.77LJFFJL7JL-FJ|-77JF|7|F-J||LJ|LJ||7FJLJ--J|.F.JJ|L-F7|L7L7L7FJL7.F||FJF--JF-J.FJFJJLJL7.L|LJL7||.F|-|L||7FL77JL|F\n-F7|J.FJ|F7||7..L-.|.FJ|.|.LF.FJF-JJ.F|.|7F77-|J7L-7LJF7L--JL-7J7LL|..LL-.LJ7|LL-JFL|FJ|F-J-FJ|L7L77.|LL7LF|J-|F7L-7|77F|J---JFJJL77JF--7.FJ\nLJ|J.F|7L|L|.|L.|FFF--LF--7.|FL7||J-FLF-7-||F-7-LJ|L--J|F-----JL-7FLJ7.|J--L-L..F7F|||FJL--7|FJ.|FJF-7.LJJ||FF77.7|||-|-|JF|JFJ7.L|J-7JF|FJ|\nLFLJ.7L|||F--7F--L7J|..L-7|F7F-JL-7.FLL7|L|LJFJ|.F7F7F-JL7F7FF77LF-7F77||L|.J.L7LF--J|L7F--J|L7FJL-JFJ7.|FF-F7JF77-|..|.JF7F7.||-L|F-J7||J7F\n7.F.J-FJ-J-LL-FJ|.|F-LF--JLJ||F---J-7|F|L7|F-J|FFJ|||L-7FJ|L7|L777F77L--F.|-|7J|JL--7L7||7F7|FJL7F7FJJ|F7FJ.FF-JL-7.F-F7|-||7--F-7LFJLLL-.FJ\n|.L7J-7J7||||LJ-FF7F7LL----7|||F-7.|F-7L7LJ|F--7L7LJ|F7|L7|FJL7|F-7JF7L7L77FF-7F77F-JFJ|L7|||L-7|||L7.LF7J.7.|F7F-J7|F-JJ--.||LL7J.7--J7|F-7\n|7JL-|LL7-J-7-FFFJLJ|7F7F-7|LJLJFJ7FJFJJL7FJL-7L7L-7||LJFJ|L7FJ|L7|JF77JF-7-L7LJ|FJF7|FJFJ|||F-J||L-J7|||LF|-LJ|L-7F7J|..7J77LFJJFL--|.J7|FL\n|--..FF-J7|||.LFL7F7L-JLJFJL-7F-JJFL7|F7L|||F7|FJF-J|L-7L-JFJL7|FJL7||J.|FJ7FJF7|L-J||L7|FJ|||F7|L7F7.F||-|F-7|L7FJ||.F7F7-7--JLF--J|LFLJF-J\nL7J.FFF-L|-7F7-7.LJL----7L-7FJ|F7LF-JL7F7|L-J||L7L-7L7J|F--JF-J|L-7LJL-7||F7L7|LJF7FJL7||L7||||||FJ||F7||F7|FJF-JL-JL-J|||7L||.|F77LL7||.||7\nF77FF-|...LFJF7|FF------JF-JL7||L7L-7FJ||L--7||FJF7L7L-JL-7FJF-JF-JF---J||||FJL7FJ|L7FJ||FJLJ||LJL-J||||||||L7|F-7F----J|L7F7J7|JF7.F|7LLL.|\nFJLFL7|7F|LLFJLLFL------7L7F7|LJFJF7||FJ|F77||||FJ|JL--7F-J|FJF7L-7|F-7FJ|||L7FJL7L7|L7||L-7FJ|F----J|LJLJLJFJ|L7LJ.F--7|FJ||.FJ7LJ7-J|F|7L|\n7-F|.JJ7LJJ||.LJJ|.F7FF7|FJ||L-7L7|||||FJ|L7|LJLJFJF7F-J|F7||||L7FJLJFJL7||L-JL7LL7||FJ||F7||FJL7F-7LL-----7L-JFJF7FJF-J|L-JL-7-F7LL.FLLJJLJ\nF---F-F|FJ.J--F|-F-JL-J||L7|L-7L7LJLJ||L7|FJL-7F-JFJ|L-7||||L7|FJ|F--J7F||L7F-7|F7|LJ|FJ||LJLJF7||FJF--7|F-JF--JFJ|L7|F7|F----J.L7-J7..J.|.|\nL7LJJFFJLFJ7|.L.FL7F--7|L7|L-7|FJF---J|FJ||-F-JL-7L7|F-J||||FJ|L-J|F--7FJ|-LJFJ|||L-7||FJ|F-7FJ|||L7L-7L7L-7|F7L|FJFJLJLJL-----7L-7LF-FJ.|F7\n.L77.LF7LJ-LLF7FF.||F-JL7|L--J|L7L7F7FJ|F|L7L-7F-JFJ|L-7LJLJL-JF--J|F-JL7|F7FJFJ||F7|LJL-JL7LJ|LJL7L-7L7|F-JLJL7||FJF7F---7F--7|-L7.|7|.J7-.\n|JL-L-7F|J|L|.F--FLJL7F7LJF7F7L-JFJ||L7L7L7|F7|L7FJFJF7L-7F----JLF7|L-7FJ|||L7L7|LJ|L----7FJ.F7|F7|F7L-J|L7F-7FJ|LJFJLJ-F7LJ7.LJ.L|.L|-J|LJ7\n|.JJ.F|-F-|7|LF-|F-7L|||F7|LJL7F7L7||FJFJ-|||||FJL7L7|L--JL7F7|F7|LJF-JL7|||JL7|L7FJF--7FJL7FJL7||LJL--7L7LJFJL7|F-JJF-7||F7F77J|.|F.|L|-|.7\n||J7FFLJLJ..|J.LFL7L-J|LJLJF-7LJ|FJ||L7|F-JLJ||L7FJFJL---7FJ|L-JLJF-JFF7|LJL7-||FJ|FJF-JL-7LJF-J|||F--7|FJF-JF-J|L7F7L7LJ||LJL7F7F7J.F7F-J7L\n-.FJF--F-.|7L-7-7-L7F-JF---JFJF-JL7||FJ|L--7FJ|FJL7|F77F7|L7|F----JF7FJ|L--7|FJ||FJ|FJF7F-JF-JF7|L7L-7LJL-JF-JF7|FJ|L7|F-JL7F-J||||F7|L-J.FJ\n|-7L|J-F-LLJ7J|JL7|LJF7L---7L7L--7LJ|L7|F--JL-JL-7||||FJ||FJ||F7F7FJ||FJF77||L7||L7|L7||L-7L-7|||FJF7L----7L-7||||7L7||L-7J||F7|||LJL777-L7J\n||J7.|7LFLF7F7|----F-JL---7L7L--7L-7||||L--7F7F--J|LJ|L7|||FJLJ|||L7|||FJ|FJL-J||FJ|FJ||F7|F-J||||FJ|F7F--JF7LJLJL7FJLJF-JFJLJLJLJF7FJJ-77|7\nLLJLF-J" <> ...}

Part 1 Solution

grid = puzzle_input |> String.to_charlist() |> Enum.reject(&amp;(&amp;1 == ?\n))

# checks out, grid is 140 x 140
Enum.count(grid) / 140

defmodule Grid do
  def at(grid, {x, y}) do
    Enum.at(grid, y * 140 + x)
  end
end

start_index = grid |> Enum.find_index(&amp;(&amp;1 == ?S))
start_pos = {rem(start_index, 140), div(start_index, 140)}
# My input start point would be an 'F', going right and down, so:

up = {0, -1}
down = {0, 1}
left = {-1, 0}
right = {1, 0}

start_dir = right
end_dir = up

path =
  Stream.unfold({start_pos, start_dir}, fn
    {^start_pos, ^end_dir} ->
      nil

    {{x, y}, {dx, dy} = dir} ->
      next_pos = {x + dx, y + dy}

      next_dir =
        case {Grid.at(grid, next_pos), dir} do
          {?|, ^up} -> up
          {?|, ^down} -> down
          {?-, ^left} -> left
          {?-, ^right} -> right
          {?L, ^down} -> right
          {?L, ^left} -> up
          {?J, ^down} -> left
          {?J, ^right} -> up
          {?7, ^right} -> down
          {?7, ^up} -> left
          {?F, ^up} -> right
          {?F, ^left} -> down
          _ -> nil
        end

      if next_dir do
        {next_pos, {next_pos, next_dir}}
      end
  end)
  |> Enum.to_list()
  |> List.insert_at(0, start_pos)

path
|> Enum.count()
|> div(2)
6864

Part 2

You quickly reach the farthest point of the loop, but the animal never emerges. Maybe its nest is within the area enclosed by the loop?

To determine whether it’s even worth taking the time to search for such a nest, you should calculate how many tiles are contained within the loop. For example:

...........
.S-------7.
.|F-----7|.
.||.....||.
.||.....||.
.|L-7.F-J|.
.|..|.|..|.
.L--J.L--J.
...........

The above loop encloses merely four tiles - the two pairs of . in the southwest and southeast (marked I below). The middle . tiles (marked O below) are not in the loop. Here is the same loop again with those regions marked:

...........
.S-------7.
.|F-----7|.
.||OOOOO||.
.||OOOOO||.
.|L-7OF-J|.
.|II|O|II|.
.L--JOL--J.
.....O.....

In fact, there doesn’t even need to be a full tile path to the outside for tiles to count as outside the loop - squeezing between pipes is also allowed! Here, I is still within the loop and O is still outside the loop:

..........
.S------7.
.|F----7|.
.||OOOO||.
.||OOOO||.
.|L-7F-J|.
.|II||II|.
.L--JL--J.
..........

In both of the above examples, 4 tiles are enclosed by the loop.

Here’s a larger example:

.F----7F7F7F7F-7....
.|F--7||||||||FJ....
.||.FJ||||||||L7....
FJL7L7LJLJ||LJ.L-7..
L--J.L7...LJS7F-7L7.
....F-J..F7FJ|L7L7L7
....L7.F7||L7|.L7L7|
.....|FJLJ|FJ|F7|.LJ
....FJL-7.||.||||...
....L---J.LJ.LJLJ...

The above sketch has many random bits of ground, some of which are in the loop (I) and some of which are outside it (O):

OF----7F7F7F7F-7OOOO
O|F--7||||||||FJOOOO
O||OFJ||||||||L7OOOO
FJL7L7LJLJ||LJIL-7OO
L--JOL7IIILJS7F-7L7O
OOOOF-JIIF7FJ|L7L7L7
OOOOL7IF7||L7|IL7L7|
OOOOO|FJLJ|FJ|F7|OLJ
OOOOFJL-7O||O||||OOO
OOOOL---JOLJOLJLJOOO

In this larger example, 8 tiles are enclosed by the loop.

Any tile that isn’t part of the main loop can count as being enclosed by the loop. Here’s another example with many bits of junk pipe lying around that aren’t connected to the main loop at all:

FF7FSF7F7F7F7F7F---7
L|LJ||||||||||||F--J
FL-7LJLJ||||||LJL-77
F--JF--7||LJLJ7F7FJ-
L---JF-JLJ.||-FJLJJ7
|F|F-JF---7F7-L7L|7|
|FFJF7L7F-JF7|JL---7
7-L-JL7||F7|L7F-7F7|
L.L7LFJ|||||FJL7||LJ
L7JLJL-JLJLJL--JLJ.L

Here are just the tiles that are enclosed by the loop marked with I:

FF7FSF7F7F7F7F7F---7
L|LJ||||||||||||F--J
FL-7LJLJ||||||LJL-77
F--JF--7||LJLJIF7FJ-
L---JF-JLJIIIIFJLJJ7
|F|F-JF---7IIIL7L|7|
|FFJF7L7F-JF7IIL---7
7-L-JL7||F7|L7F-7F7|
L.L7LFJ|||||FJL7||LJ
L7JLJL-JLJLJL--JLJ.L

In this last example, 10 tiles are enclosed by the loop.

Figure out whether you have time to search for the nest by calculating the area within the loop. How many tiles are enclosed by the loop?

Part 2 Solution

defmodule Point do
  def neighbors({x, y}) do
    [
      {x - 1, y},
      {x + 1, y},
      {x, y - 1},
      {x, y + 1}
    ]
  end

  def flood(candidates, boundary, found \\ nil) do
    found = MapSet.union(found || MapSet.new(), candidates)

    new_candidates =
      candidates
      |> Enum.flat_map(&amp;neighbors/1)
      |> MapSet.new()
      |> MapSet.difference(found)
      |> MapSet.difference(boundary)

    if MapSet.size(new_candidates) > 0 do
      flood(new_candidates, boundary, found)
    else
      found
    end
  end
end

path_points = path |> MapSet.new()

# interior is to the right of the line as we follow it

interior_points =
  path
  |> Enum.chunk_every(2, 1, [hd(path)])
  |> Enum.flat_map(fn
    [{x1, y1}, {x2, y2}] ->
      if x1 == x2 do
        [{x2 + y1 - y2, y2}, {x2 + y1 - y2, y1}]
      else
        [{x2, y2 + x2 - x1}, {x1, y2 + x2 - x1}]
      end
  end)
  |> MapSet.new()
  |> MapSet.difference(path_points)
  |> Point.flood(path_points)

# Render a pretty picture
for y <- 0..139 do
  for x <- 0..140 do
    if {x, y} in interior_points do
      "▓"
    else
      if {x, y} in path_points || {x, y} == start_pos do
        case Grid.at(grid, {x, y}) do
          ?| -> "│"
          ?- -> "─"
          ?L -> "└"
          ?J -> "┘"
          ?7 -> "┐"
          ?F -> "┌"
          ?S -> "▣"
        end
      else
        "░"
      end
    end
  end
  |> Enum.join("")
  |> IO.puts()
end

MapSet.size(interior_points)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌┐│└┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│││┌┘┌┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌──┘└┘└┐│└┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└────┐┌┘│┌┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌─┘└─┘└┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└─┐┌┐┌─┘░░░░░░░░░░░░░░░░░░░░░░┌┐░░░┌─┐░░░░░┌┐┌┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌┐░░░░░░░░░░░░░░░░░┌┐┌┐││││┌┐░░░░░░░░░░░░░░░░░░░░░░│└┐░░│┌┘░░┌┐░│└┘└┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌┘└┐░░░░░░░░░░░░░░┌─┘││└┘│└┘││░░░░░░░░░░░░░░░░░░░░░░└┐└┐┌┘└┐░░││┌┘┌──┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌┘┌─┘░░░░░░░┌┐░░░░░└─┐└┘┌┐└──┘└─┐░░░░░░░░░░░░░░░░░░░░░│┌┘│┌─┘░┌┘│└┐└┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░┌──┐░░░└┐│░░░░░┌─┐░││┌─┐░░░░└──┘│┌─────┘░░░░░░░░░░░░░░░░░░░░░││┌┘└──┐│┌┘░│┌┘┌─┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░└─┐│┌┐┌─┘└─┐░░░└┐│░│└┘┌┘░░┌┐┌┐┌─┘└┐┌┐░┌┐░░░░░░░░░░░░░░░░░░┌──┘│└┐┌──┘│└┐┌┘└─┘┌┘░░░░░░░░░┌┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░┌──┘└┘││┌───┘░░░░│└┐│┌─┘░░┌┘│││└─┐┌┘│└┐│└┐░░░░░░░░░░░░░░░░░└──┐└┐││░┌┐│┌┘└┐┌┐┌┘░░░░░░░░┌─┘└─┐░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░┌┐┌┐░└────┐│││┌─┐░░┌─┐└┐└┘│┌──┐└┐└┘│┌┐│└┐│┌┘└┐│┌─┐░░░░░░░░░┌─┐┌┐░┌─┘┌┘│└┐│││└─┐│││└┐░░┌┐░░░░│┌┐┌─┘░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░┌┘└┘│░┌┐┌─┐│└┘└┘┌┘░┌┘┌┘░└┐┌┘└─┐└┐└─┐││└┘┌┘│└┐┌┘│└┐│░┌┐░░┌─┐░└┐└┘│┌┘┌┐│┌┘┌┘│││┌─┘││└─┘░░││░░░░└┘│└─┐┌┐░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░└┐┌┐└─┘└┘┌┘└─┐┌─┘░░└┐│░░░││░┌┐│┌┘┌─┘│└─┐└─┘┌┘└┐│┌┘└┐││░░│┌┘░┌┘┌┐│└─┘││└┐│┌┘│││┌┐│└┐┌┐░░││░░┌─┐░└┐┌┘││░┌┐┌┐░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░└┘└────┐└─┐┌┘│┌┐░┌─┘└┐┌┐│└─┘││└┐└─┐└┐░│┌──┘┌─┘│└─┐└┘└─┐││┌┐└┐│└┘┌┐┌┘└┐││└┐││││││┌┘││┌┐││┌┐│┌┘┌─┘└─┘└─┘│││░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░┌──────┘┌─┘└┐││└┐└─┐┌┘││└──┐││┌┘┌┐└┐└─┘└─┐┌┘┌─┘┌─┘┌───┘││││┌┘└┐┌┘│└┐┌┘││┌┘└┘││└┘└─┘││││││││└┐│┌─┐┌────┘│└┐┌┐░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░└──────┐└┐┌┐│└┘┌┘┌┐││┌┘│┌┐░││││┌┘│░└──┐┌─┘│┌┘┌┐└─┐│┌─┐┌┘│││└┐┌┘└┐└┐│└┐││└─┐┌┘│┌────┘│└┘└┘└┘┌┘│└┐└┘░┌──┐│┌┘││░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░┌┐░┌┐│┌┘││└─┐└┐│││││┌┘│└┐│└┘└┘┌┘┌┐┌─┘│┌┐││░│└┐┌┘└┘┌┘└┐││└─┘└┐░└┐││┌┘││┌┐││┌┘└┐┌─┐░└─────┐└─┘┌┘┌┐┌┘┌─┘│└─┘└─┐░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░┌─┘└─┘││└┐│└─┐└┐└┘└┘││└┐│┌┘└─┐┌─┘┌┘│└─┐││││└┐│┌┘│┌──┘░░││└┐┌─┐│┌┐│└┘│┌┘││└┘└┘┌┐││┌┘┌──┐░┌─┘┌──┘┌┘│└┐│┌┐│┌────┘░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░└┐┌──┐│└┐│└─┐│┌┘┌───┘│┌┘││░┌─┘└─┐└┐│┌─┘││││┌┘│└─┘│┌──┐┌┘│░└┘┌┘│││└─┐││┌┘│┌─┐┌┘│││└┐└─┐└┐└─┐│┌┐░│┌┘┌┘└┘└┘└─────┐░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░││┌─┘└┐│└──┘│└┐└┐┌┐┌┘│░│└┐└─┐┌─┘┌┘│└─┐└┘└┘└─┘┌──┘│┌─┘└┐│┌┐┌┘┌┘││┌┐│└┘└─┘└┐└┘░└┘└┐└─┐└┐│┌─┘└┘└┐││┌┘┌┐┌───┐┌──┐│░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░└┘└┐┌┐└┘┌┐┌┐└─┘┌┘││└┐└┐└┐│┌┐│└┐┌┘┌┘┌┐└─┐┌────┘░┌┐│└─┐┌┘│││└┐└┐│└┘│└────┐┌┘░┌┐░┌┐│┌┐└─┘│└┐┌─┐┌┘│└┘┌┘└┘░┌┐└┘░░└┘░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░┌─┐░│││┌┐│└┘└┐┌┐└┐││┌┘┌┘░│││││┌┘└┐└┐│└──┘└┐┌┐░┌┐│└┘┌─┘└┐│││░└┐│└┐┌┘┌──┐┌┘└┐┌┘└┐││└┘└──┐└┐└┘┌┘└┐│┌─┘░┌─┐││┌┐┌┐░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░└┐└─┘│└┘└┘┌─┐└┘│┌┘││└┐│┌─┘└┘││└┐┌┘┌┘└───┐┌┘│└─┘└┘┌─┘░┌┐│└┘└┐░││┌┘│┌┘┌─┘└─┐└┘┌─┘││░┌──┐│┌┘┌─┘┌─┘│└┐┌┐└┐└┘││└┘└┐┌┐┌┐░░░░░░░░░░
░░░░░░░░░░░░░░░░░░└┐┌─┘┌───┘┌┘┌─┘└┐││┌┘│└──┐┌┘│┌┘└┐│┌┐░┌┐│└┐│┌────┘┌┐┌┘│└──┐│┌┘││┌┘│┌┘┌┐┌─┘┌─┘┌┐│└┐└─┐└┘└─┘┌─┘┌┐│┌┘│└┐│┌─┘└┐┌─┘││││┌┐░░░░░░░░
░░░░░░░░░░░░░░░░░░░└┘┌┐└───┐└┐└──┐└┘│└┐│┌──┘└─┘└─┐││││┌┘││┌┘││┌┐┌┐┌┘││┌┘┌┐░││└┐││└┐│└┐││└─┐└─┐│││┌┘┌┐└────┐└─┐││││░└┐││└─┐░││┌┐│││└┘└┐░░░░░░░
░░░░░░░░░░░░░░░░░░░┌─┘└───┐└┐└──┐└─┐│░││└──┐┌┐┌──┘│└┘│└┐│││┌┘└┘│││└┐│││┌┘│┌┘└─┘││┌┘│┌┘││┌┐│┌─┘││││┌┘│┌┐┌──┘┌┐└┘└┘└┐┌┘└┘┌─┘┌┘└┘└┘└┘┌┐┌┘░░░░░░░
░░░░░░░░░░░░░░░░░░░└─────┐│░└──┐└──┘│┌┘│┌┐░└┘│└─┐░└┐┌┘░│││││┌─┐││└┐│││││┌┘└───┐└┘│┌┘└┐│└┘││└┐┌┘││││┌┘││└───┘└─┐┌──┘│┌──┘┌─┘┌─┐┌─┐┌┘└┘░░░░░░░░
░░░░░░░░░░░░░░░░┌┐░░┌┐░┌┐││┌┐┌┐└───┐│└┐└┘└┐┌─┘┌─┘┌┐│└─┐│││└┘└┐└┘└┐└┘││└┘└─┐┌──┘┌─┘└┐┌┘└─┐││┌┘│┌┘│││└┐││┌┐┌┐┌┐┌┘└──┐│└─┐┌┘┌┐└┐│└┐│└─┐░░░░░░░░░
░░░░░░░░░░░░░░┌─┘└─┐││┌┘└┘└┘└┘└──┐┌┘└┐└┐┌─┘└─┐│┌─┘│└┐┌┘││└──┐└┐┌┐└─┐││┌───┘└──┐│░┌─┘└┐┌┐│││└─┘└┐│└┘┌┘│└┘└┘││└┘┌┐┌┐└┘┌─┘│┌┘└─┘└─┘└──┘░░░░░░░░░
░░░░░░░░░░░░░░└───┐│││└─────────┐│└┐┌┘┌┘└┐░┌┐│││┌─┘┌┘│┌┘└┐┌─┘┌┘││┌┐││││┌┐░┌┐░┌┘└┐└─┐┌┘│││└┘┌───┘└─┐└┐└──┐┌┘└┐┌┘└┘└┐┌┘┌─┘└─────────┐░░░░░░░░░░
░░░░░░░░░░░░░┌──┐┌┘└┘└───────┐┌┐│└┐│└┐└─┐└┐│││││└┐┌┘┌┘│┌─┘└─┐└─┘││││││││└┐│└┐└─┐└┐┌┘└┐││└─┐└┐┌┐┌┐░└┐└─┐┌┘│░┌┘└─┐░┌┘└─┘┌┐┌┐┌───────┘░░░░░░░░░░
░░░░░░░░░░░░░└─┐└┘┌──┐┌─────┐└┘│└┐││┌┘┌┐│┌┘│││││┌┘└┐│░││┌┐┌┐│┌──┘││││││└┐││┌┘┌┐│┌┘│┌─┘││┌┐│┌┘││││┌┐│┌─┘└┐└─┘┌─┐└┐└─┐┌─┘│││└─────┐░░░░░░░░░░░░
░░░░░░░░░░░░░░░└─┐│┌─┘│┌────┘┌┐└─┘└┘│┌┘││└┐││││││┌─┘│┌┘││││││└┐┌┐│││││└┐│││└┐│└┘│┌┘└┐┌┘└┘││└┐││││││││┌┐┌┘┌──┘░└┐└─┐│└─┐└┘└──────┘░░░░░░░░░░░░
░░░░░░░░░░░░░░░░┌┘│└─┐│└──┐┌┐│└──┐┌┐└┘┌┘│▓││││││││┌─┘└┐││││││┌┘││││││└┐└┘└┘┌┘└┐┌┘└─┐││▓┌┐│└┐││││││││││││▓└────┐└┐┌┘│┌─┘░┌────┐░┌──┐░░░░░░░░░░
░░░░░░░░░░░░░░░░└┐│┌─┘│░┌┐└┘└┘░┌┐││└─┐└┐└┐││││└┘└┘└┐┌┐│└┘└┘└┘└┐│└┘└┘└┐└───┐└┐┌┘│┌┐┌┘││┌┘└┘┌┘││││└┘│││││└┐┌────┘░└┘░└┘┌──┘┌┐┌┐└┐│┌─┘░░░░░░░░░░
░░░░░░░░░░░░░░░░┌┘││┌─┘┌┘│┌────┘└┘│┌─┘▓└┐││││└──┐┌┐└┘│└────┐┌┐│└─┐┌┐▓└┐┌──┘┌┘└┐││└┘▓└┘└─┐┌┘▓└┘└┘┌─┘│││└─┘└───┐┌──┐┌──┘┌┐┌┘└┘└─┘│└─┐░░░░░░░░░░
░░░░░░░░░░░░░░░┌┘┌┘└┘┌┐└┐└┘┌┐┌─┐┌┐│└───┐││└┘│┌┐┌┘│└──┘┌─┐┌┐││└┘┌┐└┘│┌─┘│┌┐┌┘┌┐││└─┐┌┐┌┐┌┘└────┐┌┘┌┐│││┌────┐┌┘└┐┌┘│┌─┐│││┌┐┌─┐┌┘┌─┘░░░░░░░░░░
░░░░░░░░░░░░░░░└┐│░┌─┘└─┘┌─┘│└┐└┘└┘┌───┘└┘┌─┘││└┐└─┐┌┐└┐││└┘│┌┐│└──┘│┌┐││└┘┌┘└┘│┌─┘│└┘└┘┌┐┌┐┌┐││┌┘└┘└┘└┐┌─┐└┘┌┐││┌┘└┐└┘└┘│││┌┘└┐│░░░░░░░░░░░░
░░░░░░░░░░░░░░░┌┘└┐└─────┘┌┐└─┘░┌──┘┌┐┌──┐└┐┌┘└┐│┌─┘││┌┘│└─┐│││└───┐││└┘│┌┐└──┐││┌─┘┌──┐│└┘││││└┘┌┐┌──┐└┘┌┘┌─┘└┘│└┐┌┘┌─┐┌┘││└┐┌┘└─┐░░░░░░░░░░
░░░░░░░░░░░░░░░└──┘┌──────┘│┌┐░┌┘┌─┐│└┘┌┐└┐│└─┐││└─┐││└┐│┌─┘└┘│┌───┘││┌─┘││┌┐┌┘└┘│┌┐│┌─┘└─┐└┘││┌─┘│└─┐│┌─┘┌┘┌──┐└┐││░│┌┘└┐└┘┌┘│┌──┘░┌┐░░░░░░░
░░░░░░░░░░░░░░░░┌─┐└────┐┌┐└┘└─┘┌┘░└┘┌─┘└─┘└┐┌┘└┘▓┌┘││┌┘└┘┌───┘└──┐▓└┘└┐┌┘│││└┐┌┐││└┘└─┐┌┐└─┐└┘└─┐└──┘│└─┐└┐└─┐└┐└┘└┐││┌┐│┌─┘░│└┐┌┐┌┘└┐░░░░░░
░░░░░░░░░░░░░░░░└┐│░┌───┘│└─────┘┌───┘┌┐┌┐┌┐│└┐▓┌┐└┐│││┌──┘┌┐┌┐┌─┐└───┐││▓└┘│┌┘│└┘└─┐┌─┘││┌┐└┐▓┌─┘┌──┐└─┐└─┘┌─┘░└┐┌┐└┘└┘└┘└┐┌┐└┐└┘││┌─┘░░░░░░
░░░░░░░░░░░░░┌───┘└─┘┌───┘┌──────┘┌───┘└┘│││└─┘┌┘└─┘│└┘└─┐┌┘└┘│└┐│┌┐┌─┘││┌──┘└┐│┌┐┌─┘└─┐│││└┐└┐└──┘┌┐└┐┌┘┌┐┌┘┌┐┌┐││└┐┌┐┌┐┌┐└┘└─┘┌┐└┘└─┐░░░░░░
░░░░░░░░░░░░░└────┐┌─┘┌┐┌┐└───────┘┌┐┌┐┌┐└┘│┌┐▓└┐┌─┐└┐┌──┘└┐┌─┘┌┘││└┘┌┐└┘│┌──┐│└┘│└┐┌┐┌┘│││┌┘┌┘┌┐┌─┘└─┘└─┘└┘┌┘└┘│││░││││└┘└┐┌┐┌┐│└───┐└┐░░░░░
░░░░░░░░░░░░░░┌─┐░└┘░┌┘└┘└────────┐│└┘││└──┘│└┐┌┘│▓└─┘└─┐┌┐││┌┐│┌┘└──┘└─┐││┌─┘│┌─┘┌┘│└┘┌┘│││┌┘┌┘└┘┌──┐┌┐┌┐┌┐└┐┌─┘│└┐│││└┐┌┐││└┘│└───┐└─┘░░░░░
░░░░░░░░░░░░░░└┐└─┐┌┐└────┐┌┐┌───┐│└─┐└┘┌┐┌┐│┌┘└─┘┌┐┌┐┌─┘│└┘└┘││└┐┌───┐┌┘│││┌┐│└┐┌┘▓└┐┌┘▓└┘└┘▓└───┘┌─┘│└┘└┘└─┘└─┐│┌┘└┘└─┘│└┘└─┐│┌───┘┌─┐░░░░░
░░░░░░░░░░░░░░░└─┐││└─┐┌─┐└┘└┘░┌─┘└──┘┌┐│││││└┐┌┐▓│└┘└┘┌┐└───┐││┌┘└──┐│└┐└┘└┘││┌┘└┐┌┐││▓┌───┐┌┐┌┐┌─┘┌┐│┌──┐┌┐┌──┘└┘░┌┐┌┐░│┌┐┌┐│└┘░┌┐░└┐└──┐░░
░░░░░░░░░░░░┌┐░░┌┘│└┐┌┘└┐│░┌──┐└──────┘└┘└┘││┌┘│└┐└─┐┌┐││┌┐┌─┘└┘└┐┌──┘└┐└───┐││└┐┌┘│└┘└┐└──┐└┘└┘│└──┘└┘└─┐└┘└┘┌┐┌┐┌┐│││└┐│││││└───┘└──┘┌┐┌┘░░
░░░░░░░░░░░┌┘│┌┐└┐└─┘└──┘└┐└┐┌┘░┌─────┐┌──┐└┘└─┘┌┘┌─┘│││└┘│└──┐┌─┘└┐┌─┐│┌───┘││┌┘└┐└┐┌┐│┌─┐│┌┐┌┐└──┐▓┌┐┌┐└────┘└┘││└┘└┘┌┘└┘││└┐┌┐┌──┐┌┐│└┘░░░
░░░░░░░░░░░└┐└┘└─┘┌─┐┌─┐┌┐└─┘│┌┐└┐┌──┐│└─┐│┌─┐┌┐│▓└┐┌┘│└─┐│┌┐┌┘└──┐└┘┌┘│└───┐│││┌┐└┐└┘││└┐└┘│││└┐┌┐└─┘└┘└────────┘│┌──┐└──┐└┘░└┘└┘░┌┘││└──┐░░
░░░░░░░░░░░░└────┐│░││░││└┐┌┐└┘│░││┌─┘└──┘│└┐└┘│└─┐│└┐└┐┌┘││└┘┌──┐└┐┌┘▓└┐┌┐┌┘└┘│││┌┘┌┐└┘┌┘┌┐│└┘▓└┘└┐┌──┐┌┐┌┐┌┐┌┐┌┐││┌┐└┐┌┐└──────┐┌┘┌┘└┐┌─┘░░
░░░░░░░░░░░░░┌───┘│┌┘│┌┘│░└┘│┌┐└─┘│└─────┐│┌┘▓┌┘┌─┘│┌┘┌┘└┐││▓┌┘┌┐└─┘└──┐└┘│└──┐│││└─┘│┌┐└─┘└┘┌────┐└┘┌─┘│└┘└┘││││││└┘└┐└┘└─┐┌┐┌──┘└─┘░┌┘│░░░░
░░░░░░░░░░░┌┐└─┐┌┐│└┐│└┐│┌──┘│└─┐┌┘┌───┐┌┘└┘┌┐└─┘┌┐└┘▓└┐┌┘└┘┌┘┌┘└┐┌┐┌──┘┌─┘┌──┘││└┐┌─┘│└────┐└───┐└─┐└──┘┌───┘│└┘││┌──┘░┌─┐│││└─┐┌───┐└┐└─┐░░
░░░░░░░░░┌─┘└┐░││└┘░└┘░└┘└┐┌┐│░┌┘│░└──┐└┘┌┐┌┘└───┘└──┐▓│└─┐▓└┐└─┐│││└─┐▓└─┐└─┐▓└┘▓││┌┐└┐┌──┐└─┐┌┐└─┐└───┐└────┘┌┐└┘└────┘┌┘└┘└─┐└┘┌──┘┌┘┌─┘░░
░░░░░░░░░└──┐└┐└┘░┌──┐┌┐┌─┘│└┘┌┘┌┘┌───┘┌┐│└┘┌────────┘┌┘┌┐└─┐└─┐││││┌┐└──┐│┌┐└┐▓┌┐└┘││▓└┘┌┐└─┐││└─┐└┐┌─┐└──┐┌┐┌┘│┌┐┌────┐└┐┌┐┌┐│┌┐└─┐░└─┘░░░░
░░░░░░░░░░┌┐└┐│░┌┐└┐┌┘││└──┘┌─┘┌┘░└┐▓┌─┘│└─┐└───────┐▓└─┘│┌┐└─┐└┘└┘│││┌──┘└┘│┌┘┌┘└──┘└───┘└──┘└┘┌┐│▓└┘▓└──┐└┘│└┐│││└───┐└─┘││││└┘│┌┐└──┐░░░░░
░░░░░░░░┌─┘└─┘└─┘└─┘│┌┘└─┐┌┐└─┐└┐┌┐└┐│┌─┘┌┐│┌───┐┌─┐└──┐┌┘│└┐┌┘┌┐┌─┘│└┘┌──┐▓└┘▓└─────┐┌┐┌───────┘││┌┐┌┐┌┐┌┘┌─┘┌┘└┘└┐┌─┐│┌┐┌┘└┘└┐┌┘│└┐┌─┘░░░░░
░░░░░░░░└──────┐┌─┐┌┘└──┐└┘│┌┐└─┘│└─┘│└──┘└┘└──┐│└┐│┌┐┌┘└─┘▓││┌┘└┘┌┐└──┘┌─┘▓▓▓▓▓▓┌───┘│└┘┌┐┌─┐┌┐┌┘└┘││└┘└┘░└──┘┌┐┌┐│└┐│││└┘┌┐┌─┘└┐│░└┘░░░░░░░
░░░░░░░░░┌┐┌──┐││┌┘└┐┌┐░└┐┌┘││┌─┐└───┘┌┐┌┐┌────┘└─┘└┘│└────┐└┘│┌──┘│┌┐┌┐└─┐▓▓▓▓┌─┘┌┐┌─┘┌┐││└┐└┘└┘┌─┐└┘┌┐┌┐░┌─┐┌┘└┘│└┐││││┌─┘│└─┐░└┘░░░░░░░░░░
░░░░░░░░░││└─┐│└┘└─┐││└┐┌┘└┐│││┌┘┌┐┌┐┌┘│││└─┐┌┐▓┌───┐└┐┌┐┌┐│┌─┘│┌──┘│└┘└──┘▓┌──┘┌─┘││┌─┘└┘└─┘┌──┐│┌┘┌┐│││└┐└┐││┌──┘░└┘└┘││┌┐└──┘░░░░░░░░░░░░░
░░░░░░░░┌┘└┐┌┘│┌┐┌┐││└┐│└─┐│││││┌┘└┘└┘▓└┘│┌┐└┘│┌┘┌──┘▓└┘└┘││└──┘│┌─┐└───┐▓▓▓└───┘▓▓└┘└───────┘┌┐││└┐│└┘└┘┌┘┌┘└┘└──┐┌┐┌┐┌┘└┘└───┐░░░░░░░░░░░░░
░░░░░░░░└─┐│└┐││└┘└┘└┐│└┐┌┘└┘│││└───┐▓┌┐▓└┘└─┐└┘┌┘┌─────┐┌┘│▓┌──┘│▓└┐┌─┐│▓▓▓▓▓▓┌─┐┌─┐┌┐┌──────┘└┘│┌┘│▓┌┐┌┘┌┘┌┐┌─┐┌┘│││││┌─────┐└┐░░░░░░░░░░░░
░░░░░░░░┌─┘└─┘│└────┐│└┐│└──┐│││░┌┐┌┘┌┘└────┐│┌─┘▓│┌────┘└─┘▓│┌┐┌┘┌─┘└┐││▓▓▓┌─┐└┐│└┐│││└┐┌┐┌──┐┌─┘└┐│┌┘│└─┘┌┘│└┐└┘░│││└┘└────┐└─┘░░░░░░░░░░░░
░░░░░░░░└────┐└─────┘└─┘└───┘└┘└─┘└┘▓│┌─────┘│└───┘│┌┐▓▓▓▓▓▓▓└┘││▓└───┘││▓▓▓└┐└─┘└─┘└┘│▓└┘└┘┌─┘│▓┌┐└┘└┐└───┘░└─┘░┌┐│└┘┌┐┌┐┌──┘┌┐░░░░░░░░░░░░░
░░░░┌┐┌┐┌┐┌──┘┌─┐┌┐┌───┐┌─┐┌┐┌───────┘└────┐▓└─┐┌┐┌┘│└┐▓▓▓▓▓▓▓▓││▓▓▓▓▓▓└┘▓▓▓▓└──┐┌─┐┌┐└┐▓┌┐┌┘┌─┘┌┘└┐┌┐└──┐┌┐░┌┐░┌┘└┘┌┐││││└───┘└─┐░░░░░░░░░░░
░░░░│└┘└┘└┘┌─┐└┐└┘└┘┌──┘│┌┘│└┘┌┐┌┐┌─────┐┌─┘┌─┐└┘└┘▓│┌┘▓▓▓▓▓▓▓▓└┘▓▓▓▓▓▓▓▓▓▓▓▓┌┐▓││┌┘│└┐└─┘└┘┌┘▓┌┘┌┐└┘└┐┌┐└┘└─┘└─┘┌┐┌┘└┘└┘│┌─┐┌┐┌─┘░░░░░░░░░░░
░░░░└─────┐│┌┘┌┘░┌──┘┌──┘└─┘┌─┘└┘│└┐┌┐┌┐└┘┌┐└┐└─┐┌─┐│└──┐┌┐┌┐▓▓▓▓▓▓▓▓▓▓▓▓▓▓┌┐│└┐││└─┘▓└┐▣┐┌┐│┌─┘┌┘└──┐└┘└─┐┌┐┌─┐┌┘││┌┐░┌┐└┘░└┘└┘┌┐░░░░░░░░░░░
░░░░░░░┌──┘│└┐│┌┐└──┐└┐┌────┘┌┐┌┐│░└┘└┘└──┘│┌┘┌─┘│┌┘│┌──┘│└┘│▓▓▓▓▓▓▓▓▓▓▓▓▓▓│└┘┌┘└┘┌───┐└┘└┘└┘│┌─┘┌┐┌┐└┐┌─┐└┘└┘░└┘░└┘│└┐││┌──────┘└─┐░░░░░░░░░
░░░░░░░└───┘░└┘││┌─┐└─┘└─┐┌─┐│└┘││┌──┐┌┐┌─┐└┘┌┘┌┐│└─┘└┐┌┐│┌─┘▓▓▓▓▓▓▓▓▓▓▓▓▓▓│┌┐└┐┌┐└──┐└──────┘└┐┌┘└┘└┐└┘┌┘┌────┐┌─┐░│┌┘│││┌────┐┌┐┌┘░░░░░░░░░
░░░░░░░░░░░┌──┐│└┘┌┘┌┐┌┐░│└┐││┌┐││└─┐└┘└┘▓│┌┐└─┘└┘┌───┘│││└──┐▓▓▓▓▓▓▓▓▓▓▓▓▓││└┐│││▓┌┐└──┐┌┐┌┐┌─┘└──┐┌┘┌┐└─┘┌┐┌┐└┘┌┘┌┘└┐│││└───┐└┘└┘░░░░░░░░░░
░░░░░░░░░┌┐└─┐│└─┐└─┘└┘└─┘┌┘│││└┘└──┘▓┌──┐││└┐┌─┐┌┘▓┌┐┌┘└┘┌──┘▓▓▓▓▓▓▓▓▓▓▓▓▓└┘▓││││┌┘└┐┌─┘│└┘└┘▓┌┐┌─┘└─┘└───┘││└─┐└─┘┌┐└┘││┌───┘░┌┐░░┌┐░░░░░░░
░░░░░░┌┐░││┌┐││┌┐└────┐┌┐┌┘┌┘│└───────┘┌─┘└┘┌┘└┐│└─┐│││┌─┐└───┐▓▓▓▓▓▓▓▓▓▓▓▓▓▓┌┘│││└─┐│└──┘┌──┐┌┘└┘┌────────┐└┘┌┐└───┘└─┐└┘└──┐┌─┘│┌─┘└┐░░░░░░
░░░░┌─┘└─┘│││││││┌┐┌┐░└┘└┘░└─┘┌┐░┌─────┘┌┐┌┐└──┘└──┘││││▓└────┘▓▓▓▓▓▓▓▓▓▓▓▓▓▓└┐└┘│┌┐│└───┐└─┐│└┐┌┐│▓┌───┐┌┐└──┘└──┐┌──┐│┌┐┌──┘│┌─┘│┌──┘░░░░░░
░░░░└──┐┌┐││││││││││└──┐░┌┐┌──┘└┐└─────┐│└┘└────────┘└┘└┐┌───┐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓└─┐└┘││┌──┐│▓┌┘└┐││││┌┘┌─┐└┘│┌──────┘└┐┌┘│││└───┘└──┘└┐┌┐░░░░░░
░░░░┌─┐└┘││││││││││└──┐└─┘│└─┐┌┐│┌────┐└┘┌───┐┌┐┌────┐┌┐└┘┌──┘┌──┐▓▓▓▓▓▓▓▓▓▓▓┌┐▓└┐┌┘└┘┌─┘└─┘┌┐└┘│└┘│┌┘▓└─┐│└─┐┌┐┌┐┌─┘└┐│││┌┐┌┐┌┐┌┐┌┐└┘└─┐░░░░
░░░░└┐│┌┐│└┘└┘└┘└┘│░┌┐└──┐│┌┐└┘││└───┐│┌┐└──┐└┘│└───┐└┘│┌┐│┌┐▓│┌─┘▓▓▓▓▓┌┐▓▓▓┌┘│┌─┘│▓┌┐└┐┌┐┌┐│└┐┌┘┌─┘│┌───┘└──┘│││││┌──┘└┘││││└┘└┘│││┌┐┌┐└┐░░░
░░░░┌┘└┘│└─┐┌┐┌┐┌┐└─┘└─┐░│└┘└┐┌┘└────┘└┘└──┐└┐┌┘┌─┐┌┘┌┐││││││┌┘└─┐▓▓▓┌┐│└─┐┌┘┌┘└─┐└┐││▓││└┘└┘▓└┘┌┘┌─┘└──────┐┌┘└┘└┘└──┐┌┐││└┘░┌─┐││└┘││└─┘░░░
░░░░└┐┌┐└──┘│││└┘└────┐└┐└──┐│└┐┌─────────┐│┌┘└─┘▓││▓││└┘└┘│││┌──┘▓▓┌┘││┌─┘└┐└┐┌─┘┌┘│└─┘└┐┌───┐┌┘┌┘┌─┐▓┌───┐└┘┌──┐┌───┘││└┘░┌─┘┌┘│└┐░└┘░░░░░░
░░░░░└┘└──┐┌┘││┌┐┌┐┌┐░└┐└┐┌┐│└┐└┘┌───────┐││└────┐│└─┘└┐┌┐┌┘└┘└─┐┌┐▓└┐││└┐▓▓└┐└┘┌┐└┐└────┘└──┐│└─┘▓└┐└┐└──┐│┌┐└┐░│└────┘└───┘┌┐└┐│┌┘┌┐┌┐░░░░░
░░░░░┌────┘│░│││└┘└┘└─┐└┐││││┌┘┌┐└──────┐└┘└─┐┌┐┌┘│┌─┐┌┘│└┘┌─┐┌┐││└┐┌┘││┌┘┌──┘┌─┘└┐└┐▓┌──┐┌──┘└─┐┌─┐└┐└─┐┌┘││└┐└┐└─┐┌┐┌──────┘└─┘└┘░│└┘└┐░░░░
░░░░░└────┐└┐└┘└─┐┌┐┌┐└─┘└┘└┘└─┘└────┐┌┐└┐┌─┐└┘││▓└┘┌┘└┐└┐┌┘▓└┘└┘│┌┘└┐││└┐└───┘▓┌┐└┐└┐└┐┌┘└───┐┌┘└┐│┌┘┌┐│└┐││░└┐└─┐│││└──────┐┌┐░░┌─┘┌─┐│░░░░
░░░░░┌────┘┌┘░┌──┘│└┘│┌────┐┌┐┌─┐┌──┐││└┐└┘┌┘┌┐└┘┌─┐│┌┐│┌┘│▓┌┐▓┌┐│└┐▓││└┐│▓▓┌┐▓┌┘└┐└┐└─┘└┐┌┐┌─┘│┌┐│││┌┘│└─┘└┘┌┐└──┘└┘│┌───┐┌─┘│└─┐│┌─┘░││░░░░
░░┌──┘┌┐┌┐┌┘┌─┘┌──┘┌┐└┘┌───┘│││┌┘│┌─┘└┘┌┘┌┐└─┘└┐┌┘┌┘└┘││└┐└┐│└┐│││┌┘┌┘└┐│└─┐│└┐└┐┌┘┌┘┌──┐│││└─┐└┘└┘│└┘▓└───┐░│└─────┐│└──┐│└─┐└┐┌┘││░░░└┘░░░░
░░└──┐││││└┐└─┐│┌──┘└──┘┌┐┌┐│└┘└┐│└──┐▓└─┘└──┐┌┘└┐│▓┌┐└┘▓└┐└┘┌┘││││▓└─┐││┌─┘│┌┘┌┘└─┘┌┘┌─┘│││┌┐└───┐│▓┌┐┌──┐└─┘┌────┐│└┐┌┐││┌┐└─┘└─┘└┐░░░░░░░░
░░░░░└┘└┘└─┘┌┐││└────┐┌┐│││││┌─┐└┘┌──┘┌─┐▓┌─┐│└┐┌┘│┌┘└┐┌──┘┌─┘┌┘└┘│┌┐┌┘└┘└─┐││┌┘┌─┐┌┘┌┘┌┐└┘└┘└─┐┌┐│└┐││└─┐└──┐└───┐└┘░└┘└┘││└┐┌┐┌──┐└┐░░░░░░░
░░░░░░░░┌┐┌┐││└┘┌┐┌──┘│││││└┘└┐│┌┐└─┐▓└┐│┌┘┌┘└┐└┘┌┘└┐┌┘└─┐┌┘┌┐└─┐┌┘│└┘┌──┐┌┘││└─┘▓└┘▓└┐││┌┐┌──┐│││└┐│││┌┐└──┐│┌┐┌┐└┐┌─┐┌┐┌┘└┐└┘│└┐┌┘┌┘░░░░░░░
░░░░░░░┌┘└┘└┘│┌┐││└───┘└┘└┘░┌─┘└┘└──┘┌┐│││┌┘┌┐└─┐│┌─┘└┐┌┐│└┐│└┐▓││▓└─┐└─┐└┘▓││┌─┐▓┌┐┌┐└┘└┘└┘┌─┘└┘└─┘└┘└┘└───┘││└┘│┌┘│┌┘││└─┐└┐░└─┘└─┘░░░░░░░░
░░░░┌──┘┌┐┌─┐└┘└┘│░┌┐┌┐░┌┐┌┐│┌───────┘└┘└┘└┐││┌┐└┘└──┐││││┌┘│┌┘┌┘│┌┐┌┘┌─┘┌─┐│││┌┘┌┘└┘└┐┌──┐▓└┐┌┐┌┐┌┐┌─┐┌────┐│└─┐│└─┘└─┘└─┐└┐└───┐░░┌┐┌┐░░░░░
░░░░└─┐┌┘││┌┘┌┐┌┐└─┘└┘│┌┘└┘│└┘┌┐┌──────┐┌─┐└┘└┘└─┐▓┌┐│││││└┐│└┐└┐│││└┐│┌┐└┐└┘││└┐└┐┌──┘└─┐│┌┐└┘│││││└┐└┘▓┌──┘└──┘└────┐┌──┘┌┘┌┐┌─┘░┌┘└┘│░░░░░
░░░░░┌┘│░└┘└┐│││└┐┌──┐│└──┐│┌┐││└────┐┌┘└┐└┐┌────┘┌┘└┘└┘││┌┘│┌┘▓││││┌┘└┘└┐│┌┐└┘┌┘▓││┌┐▓┌┐││││┌─┘│└┘│┌┘┌──┘┌──────────┐│└┐┌┐└─┘│└───┘┌┐┌┘░░░░░
░░░░░└─┘┌┐┌┐└┘││░└┘┌─┘└───┘└┘└┘└┐┌───┘└┐┌┘▓└┘▓┌──┐└──┐┌┐└┘└┐│└┐┌┘│││└┐┌──┘└┘│┌─┘┌┐││││┌┘└┘└┘│└─┐└─┐└┘┌┘┌─┐│┌──────┐┌─┘└┐└┘└─┐░│┌┐┌┐┌┘└┘░░░░░░
░░░░░░░░│└┘└──┘└┐░┌┘┌┐┌─┐┌─────┐└┘┌┐┌─┐│└────┐│┌─┘┌──┘│└──┐││┌┘└┐│││┌┘└─┐┌──┘│┌┐│││└┘│└┐┌┐┌┐└─┐└──┘┌─┘┌┘▓└┘└─┐░┌─┐││┌─┐└┐┌─┐└┐└┘│││└┐░░░░░░░░
░░░░░░░░└───┐┌─┐│┌┘┌┘└┘░└┘┌┐┌─┐└─┐│└┘┌┘│┌┐┌──┘│└┐▓└───┘┌┐┌┘│││┌┐│││││┌──┘└─┐┌┘││││└─┐│▓└┘└┘│┌┐└───┐└┐┌┘┌─────┘┌┘┌┘└┘│┌┘░└┘┌┘┌┘░░└┘│┌┘░░░░░░░░
░░░░░░░░┌───┘│┌┘│└┐└┐┌────┘└┘┌┘░┌┘│┌─┘▓└┘└┘┌┐▓└┐│┌┐▓┌┐▓│││┌┘││││││││││┌─┐┌─┘└┐││││┌┐││┌┐┌┐┌┘││┌───┘▓└┘▓└────┐░│┌┘░┌┐│└───┐│┌┘░░┌┐░└┘░░░░░░░░░
░░░░░░░░└───┐│└┐│┌┘┌┘└──────┐└──┘┌┘│┌┐▓┌┐▓┌┘│┌┐││││┌┘│┌┘└┘└─┘││││└┘││││┌┘└┐┌─┘│││││││└┘│││└─┘│└┐┌┐▓┌┐▓┌┐▓┌──┘┌┘└──┘└┘┌┐┌┐│││┌┐┌┘│░░░░░░░░░░░░
░░░░░░░░░░░░└┘┌┘│└┐└┐░┌┐┌───┘┌─┐┌┘░└┘└─┘└┐└┐││││││││┌┘└────┐┌┘││└─┐└┘││└┐┌┘└─┐│└┘└┘│└─┐└┘│┌─┐└┐└┘└┐││┌┘└┐└───┘┌┐┌─┐┌─┘└┘└┘│└┘└┘┌┘░░░░░░░░░░░░
░░░░░░░░░░░░░░└┐│░└─┘┌┘└┘┌┐┌┐└┐└┘┌┐┌─┐┌──┘┌┘││└┘││││└┐┌─┐┌─┘└┐│└─┐│┌─┘│┌┘│┌──┘└──┐┌┘┌─┘┌─┘└┐└┐│┌──┘││└┐┌┘┌┐┌┐┌┘│└┐│└────┐┌┘┌──┐└┐░┌┐░░░░░░░░░
░░░░░░░░░░░░░░░└┘┌┐┌─┘┌─┐│└┘└┐│┌─┘└┘▓└┘┌─┐└┐│└─┐│││└┐│└┐│└──┐│└─┐└┘└┐┌┘└┐│└┐▓┌┐┌─┘└┐└┐┌┘▓┌┐│┌┘│└┐┌┐││┌┘└─┘│││└┐│┌┘└──┐┌─┘└┐└─┐└─┘┌┘│░░░░░░░░░
░░░░░░░░░░░░░░┌──┘│└─┐│░└┘┌──┘│└──────┐│┌┘▓││┌┐││││┌┘│┌┘│┌─┐│└┐▓└──┐││┌─┘└┐│┌┘│└──┐│┌┘│┌┐│││└┐│┌┘│└┘│└───┐└┘└─┘│└───┐└┘┌─┐└──┘┌─┐└┐│░░░░░░░░░
░░░░░░░░░░░░░░└──┐│┌┐││┌──┘┌┐┌┘░┌┐░┌──┘│└┐┌┘││││││││┌┘└┐│└┐└┘┌┘┌┐┌─┘└┘└─┐┌┘└┘┌┘▓┌─┘│└┐│││││└┐│││▓└┐┌┘┌┐┌┐└─┐┌─┐└────┘┌┐│┌┘┌┐┌┐│┌┘░││░░░░░░░░░
░░░░░░░░░░░░░░┌──┘└┘└┘│└─┐┌┘││┌─┘└─┘┌─┐│┌┘└┐│││││││││┌─┘└┐│┌┐└─┘│└─┐┌───┘└─┐┌┘┌┐└─┐└┐│└┘│││┌┘││└┐┌┘│┌┘└┘│┌─┘│┌┘┌─────┘││└─┘└┘└┘└┐░││┌┐┌┐░░░░░
░░░░░░░░░░░░░░└┐┌┐┌┐┌┐│┌─┘│░└┘└┐┌──┐└┐│││▓▓││││││││││└┐┌─┘└┘│┌──┘┌┐││▓┌┐▓┌┐││▓││┌┐└┐│└─┐│││└┐││┌┘└┐│└─┐┌┘└──┘└─┘┌┐┌┐┌┐└┘┌┐┌┐┌┐┌┐└─┘└┘└┘│░░░░░
░░░░░░░░░░░░░░┌┘│└┘││└┘│┌─┘┌───┘│┌┐│┌┘││└┐┌┘└┘│││││││┌┘└┐┌┐┌┘└─┐┌┘└┘│┌┘│┌┘││└┐││││┌┘└┐┌┘││└┐│││└┐┌┘│┌┐││┌┐┌─┐┌──┘└┘└┘│┌─┘└┘└┘└┘└┐┌┐┌┐┌─┘░░░░░
░░░░░░░░░░░░░░└┐│░┌┘│┌─┘│┌─┘┌───┘│└┘│┌┘└┐││┌┐░└┘│││││└┐┌┘││└┐┌─┘│░┌─┘│┌┘└┐││░││││││┌┐└┘┌┘│░│││└┐││┌┘││││││└┐│└───┐┌─┐│└┐┌┐░┌┐┌─┐└┘└┘└┘░░░░░░░
░░░░░░░░░░░░░░░└┘┌┘┌┘└──┘└──┘┌───┘┌┐│└┐┌┘│└┘│┌──┘│└┘│┌┘└┐│└┐│└─┐└┐└─┐│└┐┌┘└┘┌┘││││└┘└─┐└┐└┐└┘└┐││││┌┘││││└┐││┌┐┌┐└┘┌┘└┐└┘└─┘││┌┘░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░└─┘┌┐░┌──┐┌┐└───┐│││░└┘░└─┐│└┐┌┐└─┐││┌┐│└┐││┌─┘┌┘┌─┘│┌┘└──┐└┐││││┌┐┌┐└┐└┐└┐░░└┘││└┘░││││┌┘│└┘└┘│┌┐└─┐│┌┐┌─┐└┘└┐┌┐░░░░░░░░░░░
░░░░░░░░░░░░░░░░░┌──┘└─┘┌┐└┘└────┘││└┐░┌───┘│┌┘│└─┐││││└┘┌┘└┘└─┐└┐└┐┌┘│┌─┐┌┘░└┘││││││└┐└┐└┐└┐┌┐┌┘└──┐││└┘└┐└──┐░└┘│┌┐│└┘│└┐│┌─┐└┘│░░░░░░░░░░░
░░░░░░░░░░░░░░░░░└─┐┌─┐┌┘└┐┌─┐┌┐┌┐│└┐└┐│┌─┐┌┘└┐└┐░└┘││└─┐│┌────┘┌┘┌┘└┐│└┐│└┐░┌┐││└┘││░└─┘░└┐└┘││┌─┐┌┘││┌──┘┌─┐│┌─┐││││┌┐└─┘└┘░└┐┌┘░░░░░░░░░░░
░░░░░░░░░░░░░░░░┌┐┌┘│┌┘│┌─┘│░└┘└┘│└┐└┐││└┐│└┐░└┐└─┐┌┘│┌─┘││┌─┐┌┐└┐└┐┌┘└─┘│┌┘┌┘└┘└┐┌┘└──┐░┌─┘┌┐││└┐││░└┘└┐┌┐└┐│└┘┌┘└┘└┘││┌───┐┌┐└┘░░░░░░░░░░░░
░░░░░░░░░░░░░░░┌┘└┘┌┘└─┘│┌┐└┐┌───┘┌┘┌┘│└─┘└┐└─┐└┐┌┘│┌┘└─┐│└┘┌┘│└┐└┐│└───┐││░└┐┌─┐│└─┐┌┐│┌┘┌┐│││└┐││└─┐┌─┘│└┐││┌┐└┐┌┐┌─┘└┘┌─┐└┘└┐░░░░░░░░░░░░░
░░░░░░░░░░░░░░░│┌┐┌┘░┌┐┌┘│└┐│└┐┌─┐│░└┐└──┐┌┘┌┐└┐││░││┌──┘└┐░│┌┘┌┘┌┘│┌───┘└┘┌─┘└┐└┘┌┐││└┘└┐│││││┌┘││┌┐│└┐┌┘░││││└┐││└┘┌──┐└┐│┌┐┌┘░░░░░░░░░░░░░
░░░░░░░░░░░░░░┌┘│││░┌┘└┘┌┘┌┘│░│└┐└┘┌─┘┌┐┌┘│┌┘│┌┘│└┐└┘└─┐┌┐└┐│└┐└┐└┐│└──┐░┌┐└┐┌┐└┐░││││░┌─┘│││└┘└┐│└┘│└┐││┌─┘││└┐│└┘┌┐└─┐│┌┘└┘└┘░░░░░░░░░░░░░░
░░░░░░░░░░░░░░└┐│││┌┘┌┐┌┘░└┐│┌┘┌┘┌─┘┌┐│││┌┘│┌┘│░└┐└┐┌──┘│└┐││┌┘░└┐│└┐┌┐│┌┘└─┘│└┐└─┘│││┌┘┌┐││└┐░┌┘└┐░│┌┘└┘│┌┐││┌┘└──┘└─┐│└┘░┌┐░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░││││└┐│└┘░┌─┘│└┐└┐│┌┐│││││└┐││┌┘┌─┘┌┘└─┐┌┘┌┘││└─┐┌┘└┐└┘│││┌─┐┌┘░│┌─┐│└┘└┐│└┘└┐└┐│┌┐└┐││░┌─┘││││└──────┐│└──┐│└┐░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░└┘└┘░││░┌┐└──┘░└┐│││││││└┘┌┘│└┘┌┘┌┐│┌──┘└┐│┌┘│┌┐││┌┐└┐░│││└┐││┌─┘└┐└┘┌──┘└┐░░└┐│└┘└─┘│└┐└─┐│└┘│┌──────┘└┐┌┐└┘┌┘░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░││┌┘└─┐┌───┘│└┘└┘││┌┐└┐└─┐└┐│││└┐┌┐┌┘│└┐││││└┘│┌┘┌┘││┌┘└┘└┐┌┐└─┐└┐┌─┐└┐┌┐│└────┐└┐└┐┌┘└─┐│└───┐┌──┐││└──┘░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░└┘└──┐└┘┌┐┌┐│┌───┘└┘└┐└─┐└┐│││└┐││││┌┘┌┘│││└─┐│└┐│┌┘││░┌──┘│└──┘┌┘└┐│┌┘│└┘┌─┐┌─┘░└─┘└┐┌┐│└┐┌─┐└┘┌┐││└───┐░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░┌─┘┌┐│└┘└┘│┌┐┌─┐┌─┘┌┐│┌┘└┘│┌┘││└┘└┐│░││└┐┌┘│┌┘└┘░││┌┘┌─┐└──┐░└┐┌┘││┌┘┌┐│┌┘└──┐░┌──┘│└┘░││░└┐┌┘└┘└┐┌──┘░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░└┐┌┘││┌───┘│└┘░│└─┐│└┘│┌──┘│░│└┐░┌┘└┐└┘░││┌┘└──┐┌┘│└┐│┌┘┌─┐└┐┌┘└┐└┘│┌┘└┘│┌┐┌┐└┐└┐┌┐└──┐││┌┐│└─┐░░│└┐░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░┌┘│┌┘│└───┐│┌┐┌┘┌┐││┌┐│└──┐└┐│┌┘┌┘┌┐│┌──┘│└─┐┌─┘│┌┘░││└┐│┌┘┌┘└┐┌┘┌─┘└─┐░│││││┌┘░│││┌──┘│││└┘┌┐└┐░│┌┘░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░└┐│└┐│░┌──┘││└┘┌┘││└┘│└┐┌┐│┌┘│└┐└┐│└┘└┐┌┐│┌┐└┘┌─┘└─┐││┌┘│└┐│░░└┘░└─┐┌┐│┌┘│└┘│└┐┌┘││└──┐│││┌┐│└─┘┌┘└┐░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░└┘┌┘│┌┘┌─┐││┌┐│░└┘░┌┘┌┘│└┘└┐│┌┘░│└┐┌┐└┘│└┘└┐┌┘┌┐┌─┘│││┌┘┌┘└┐░░┌──┐└┘││└┐└─┐│┌┘└─┘│┌┐┌┘│││││└──┐└┐┌┘░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░└┐││┌┘░└┘│││└───┐└─┘┌┘┌┐┌┘│└┐┌┘┌┘│└──┘┌┐┌┘│┌┘│└─┐││││┌┘┌┐└┐┌┘┌┐└─┐││░│┌┐││└─┐┌─┘│││░└┘└┘│┌──┘░└┘░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░┌┘│││░░┌─┘││┌┐┌┐└─┐░└┐││└┐│┌┘└┐└┐│┌─┐┌┘││┌┘│┌┘┌┐│││└┘└─┘└┐└┘┌┘└┐┌┘└┘┌┘│││└┐┌┘│┌┐││└───┐┌┘└─┐░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░└┐│└┘░░└┐┌┘│││││┌─┘┌─┘││┌┘│└─┐│┌┘││░│└┐││└─┘└┐│└┘└┘┌─────┘┌─┘┌─┘└──┐└┐│││░└┘░││└┘│┌┐┌─┘└┐┌┐│░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░│└┐░░░░└┘┌┘│└┘│└─┐└┐┌┘││░│┌┐│││░└┘┌┘┌┘└┘┌───┘└┐┌──┘┌────┐└─┐│┌─┐┌┐│┌┘││└┐┌┐░│└┐░││└┘░░░└┘└┘░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░└─┘░░░░░░└┐│┌┐│┌┐└┐└┘┌┘└┐││└┘│└┐░░└┐└┐░░└─┐┌┐┌┘└┐┌┐│┌───┘┌─┘└┘░││└┘└┐│└┐└┘└┐│┌┘┌┘└┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌┘└┘│││└┐└─┐│┌┐││└─┐└┐│░░░└─┘░░░┌┘││└┐░││└┘└──┐┌┘┌─┐┌─┘└──┐││░└┐┌─┘││░└┐┌┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└┐┌─┘└┘░└──┘││││└┐┌┘░└┘░░░░░░░░░└┐│└┐│┌┘└┐░┌──┘└─┘┌┘└┐┌─┐┌┘└┘┌┐│└─┐││┌─┘│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│└┐░░░░░░┌─┘│││┌┘└┐░░░░░░░░░░░░░││░└┘└┐┌┘░│┌┐┌┐┌┐│┌┐││┌┘└┐░┌┘└┘┌┐││││┌─┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└─┘░░░░░░└──┘└┘└┐┌┘░░░░░░░░░░░░░└┘░░░░││┌─┘│││││└┘││││└──┘░└──┐│└┘└┘└┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└┘░░░░░░░░░░░░░░░░░░░░└┘└─┐│└┘│└──┘│││░░░░░░░░└┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌──┘└┐┌┘┌┐┌─┘│└─┐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└─┐┌┐│└┐││└┐░└┐┌┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░┌┘│└┘░└┘└─┘░░└┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└┐│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░└┘░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
349

Scanline Rasterizer Version

While the flood-fill algorithm is fun and all, a more efficient way to determine interior vs exterior points of the shape is a “scanline rasterizer”-inspired algorithm, simply scanning over each line and changing whether we’re inside or outside the shape whenever we cross over the boundary.

We need to pick our horizontal “line” to be either above or below the horizontal portions of the maze. We’ll pick above and count only the ascending corners (Ls and Js) along with | rather than the descending corners. (F and 7)

for y <- 0..139, x <- 0..139, reduce: {0, false} do
  {count, inside?} ->
    if {x, y} in path_points do
      {count, if(Grid.at(grid, {x, y}) in [?L, ?J, ?|], do: not inside?, else: inside?)}
    else
      {count + if(inside?, do: 1, else: 0), inside?}
    end
end
|> elem(0)
349
path_indexes = MapSet.new(path_points, fn {x, y} -> 140 * y + x end)

grid
|> Enum.with_index()
|> Enum.reduce([], fn {x, i}, idxs ->
  inside = i - 1 == List.first(idxs)
  inside = if i in path_indexes and x in [?L, ?J, ?|], do: not inside, else: inside
  if inside, do: [i | idxs], else: idxs
end)
|> Enum.count(&amp;(&amp;1 not in path_indexes))
349