Problems
Decoration
Decoration
After all these months of lockdown, you are tired of the interior decoration of your home and decide to redesign it. Hence, you read many blog posts and magazines about Feng Shui decorating and other recent trends on home design. After some time of thinking, you decide to reproduce the idea of the famous designer Sweta Marc for replacing your bookcase with a new one you will build.
According to S. Marc, a harmonious bookcase always has several shelves spaced in an heterogeneous manner, and always following some very precise rules. More precisely, such a bookcase has a serenity value $n$ and is composed of $k + 1$ shelves spaced by $s_1,\ldots, s_k$ millimeters between each other, from the bottom to the top. According to S. Marc ideals, these spaces should verify the following properties:
1. They should be heterogeneous, i.e., no two spaces have the same height.
2. They should be not too high, i.e., for all $i \in [1, k]$, we should have $0 \le s_i < n$. Note that one of these spaces might actually have size $0$: this is one of the oddities which make Sweta’s tastes so visually attractive (arguably, this is a loss of space, but you are ready for that in the name of elegance, well-being... and trendiness).
3. They should be serene, i.e., for all $i \in [1, k - 1]$, Sweta prefers if $s_{i+1}$ is congruent modulo $n$ to $s_i$ plus the number of divisors of $s_i$ (Yes, Ms. Marc is sophisticated and loves arithmetic). You tried to design a bookcase according to the advice of Sweta Marc, but you find it hard to satisfy all the requirements. The only few solutions you found result in a bookcase which is too tall for your place.
Therefore, you decide to write a program which, given the number of shelves $k$ and the serenity value $n$, computes the values of the spaces $s_1,\ldots,s_k$ of one of the minimum height bookcases, i.e. a bookcase where the sum of spaces $s_1 + \ldots + s_k$ is the smallest.
\InputFile
Two integers $n$ and $k~(1 \le n, k \le 10^6)$.
\OutputFile
The output should contain a single line containing either:
\begin{itemize}
\item $-1$ if it is not possible to satisfy Sweta Marc’s prescriptions for the given values of $k$ and $n$,
\item otherwise $k$ integers $s_1, \ldots ,s_k$, corresponding to the spaces between the shelves of one of the minimum height bookcases satisfying the constraints. If several solutions are possible, the output should contain any of them.
\end{itemize}
Input example #1
18 10
Output example #1
11 13 15 1 2 4 7 9 12 0
Input example #2
168 9
Output example #2
1 2 4 7 9 12 18 24 32