There's a timber wood company that spans several countries. Associated with the company, there are $$$N_0$$$ countries, numbered from $$$0$$$ to $$$N_0-1$$$. In total, there are $$$N_0N_1$$$ cities, numbered from $$$0$$$ to $$$N_0N_1-1$$$ such that city $$$x$$$ belongs in country $$$\lfloor\frac{x}{N_1}\rfloor$$$. In total, there are $$$N_0N_1N_2$$$ locations that the company operates in. These locations are numbered from $$$0$$$ to $$$N_0N_1N_2-1$$$ such that location $$$x$$$ belongs in city $$$\lfloor\frac{x}{N_2}\rfloor$$$.
There is a truck driver who has to drive her truck carrying wood logs around all $$$N_0N_1N_2$$$ locations. The truck must start in any one of these locations, then go to every single one of the other locations any order, then end the journey in any location. She can visit a location more than once.
Since the truck driver likes to pee carelessly wherever she goes, there is an additional restriction to the entire journey. For each city, once the truck leaves the city, it can't go back into that city. The same thing applies to each country. Once the truck leaves a country, it can't go back into that country.
There are three different fees, denoted by three functions $$$f$$$, $$$g$$$, and $$$h$$$, each with two parameters.
For any pair $$$(x,y)$$$ ($$$x \lt y$$$), when the driver wants to drive her truck directly from location $$$x$$$ to location $$$y$$$ or vice versa, she must do all of the following three things:
There are some special properties for the values of functions $$$f$$$ and $$$g$$$.
Gold coins are way more valuable than silver coins, and silver coins are way more valuable than bronze coins. Let's say the total gold, silver, and bronze coins of the entire journey are denoted as $$$p$$$, $$$q$$$, and $$$r$$$. Find the lexicographically minimum array $$$[p,q,r]$$$!
The first line contains three integers $$$N_0$$$, $$$N_1$$$, and $$$N_2$$$ ($$$2 \leq N_0 \leq 11$$$; $$$2 \leq N_1 \leq 10$$$; $$$2 \leq N_2 \leq 9$$$) — the number of countries, the number of cities in each country, and the number of locations in each city.
The $$$i$$$-th of the next $$$N_0-1$$$ lines contains $$$N_0-i$$$ integers $$$f(i-1,i),f(i-1,i+1),f(i-1,i+2),\ldots,f(i-1,N_0-1)$$$ ($$$1\leq f(x,y)\leq10^{17}$$$) — the gold coin costs for travelling between different countries.
The $$$i$$$-th of the next $$$N_0N_1-1$$$ lines contains $$$N_0N_1-i$$$ integers $$$g(i-1,i),g(i-1,i+1),g(i-1,i+2),\ldots,g(i-1,N_0N_1-1)$$$ ($$$1\leq g(x,y)\leq10^{16}$$$) — the silver coin costs for travelling between different cities.
The $$$i$$$-th of the next $$$N_0N_1N_2-1$$$ lines contains $$$N_0N_1N_2-i$$$ integers $$$h(i-1,i),h(i-1,i+1),h(i-1,i+2),\ldots,h(i-1,N_0N_1N_2-1)$$$ ($$$1\leq h(x,y)\leq10^{15}$$$) — the bronze coin costs for travelling between different locations.
For any pair of pairs $$$(x,y)$$$ and $$$(x',y')$$$ ($$$x \lt y$$$; $$$x' \lt y'$$$; $$$(x,y)\neq(x',y')$$$), if $$$f(x,y)\leq f(x',y')$$$ holds, then $$$2f(x,y)\leq f(x',y')$$$ also holds.
For any pair of pairs $$$(x,y)$$$ and $$$(x',y')$$$ ($$$x \lt y$$$; $$$x' \lt y'$$$; $$$(x,y)\neq(x',y')$$$), if $$$\lfloor\frac{x}{N_1}\rfloor=\lfloor\frac{y}{N_1}\rfloor=\lfloor\frac{x'}{N_1}\rfloor=\lfloor\frac{y'}{N_1}\rfloor$$$ holds and $$$g(x,y)\leq g(x',y')$$$ holds, then $$$2g(x,y)\leq g(x',y')$$$ also holds.
For any pair of pairs $$$(x,y)$$$ and $$$(x',y')$$$ ($$$x \lt y$$$; $$$x' \lt y'$$$; $$$(x,y)\neq(x',y')$$$), if $$$\lfloor\frac{x}{N_2}\rfloor=\lfloor\frac{y}{N_2}\rfloor=\lfloor\frac{x'}{N_2}\rfloor=\lfloor\frac{y'}{N_2}\rfloor$$$ holds and $$$h(x,y)\leq h(x',y')$$$ holds, then $$$2h(x,y)\leq h(x',y')$$$ also holds.
A single line containing three integers representing the lexicographically minimum array of the number of gold, silver, and bronze coins for the entire journey.
2 3 231 6 9 7 93 3 2 89 8 92 944 1 2 1 3 4 2 2 3 4 24 1 1 4 2 3 1 3 2 42 3 4 1 3 3 1 4 23 4 2 2 4 2 3 21 2 2 4 2 3 33 3 2 4 1 24 2 2 3 11 3 2 21 3 12 43
3 16 21
One possible optimal journey is as follows:
Total gold coins is $$$3$$$. Total silver coins is $$$4+2+3+1+6=16$$$. Total bronze coins is $$$3+1+1+1+1+4+1+2+1+4+1+1=21$$$.