A circle is divided into $n$ sectors ($1 \le n \le 6$). You place one positive integer in each sector; every value must be at least $k$.
A number is reachable if it equals the value of a single sector, or the sum of the values of two or more consecutive sectors along the circle. Because the sectors form a circle, a block of consecutive sectors may wrap around from the last sector back to the first. In total there are $n(n-1)+1$ distinct blocks: the $n$ single sectors, the blocks of length $2, 3, \dots, n-1$, and the one whole circle.
Choose the sector values so that the reachable numbers contain every integer of the unbroken run $m, m+1, m+2, \dots, i$, and make the largest value $i$ as large as possible.
For example, with $n = 5$, $m = 2$, $k = 1$ the arrangement $(1, 3, 10, 2, 5)$ around the circle makes every integer from $1$ to $21$ reachable, so $i = 21$.
Three integers $n$, $m$, and $k$ ($1 \le n \le 6$, $1 \le m \le 20$, $1 \le k \le 20$), given in this order and separated by whitespace or newlines.
It is guaranteed that $k \le m$, so the value $m$ is always reachable (place a sector equal to $m$).
Print a single integer: the largest $i$ such that every integer from $m$ to $i$ inclusive is reachable.
Consider the example $n = 5$, $m = 2$, $k = 1$ with the circular arrangement $(1, 3, 10, 2, 5)$. Summing every block of consecutive sectors (wrapping around when needed) yields all integers from $1$ to $21$:
Every value in $[2, 21]$ appears, so the answer for this case is $i = 21$.