Josh is playing with number pyramids! A number pyramid consists of rows, labelled from to from top to bottom. The -th row contains cells, each containing a single integer between and (inclusive).
A number pyramid has a special property; each cell (apart from those on the -th row) contains an integer equal to the sum of the two integers in the cells directly below it, modulo . Formally, if is the integer written in the -th cell (from the left) of the -th row, then mod . A number pyramid with and is shown below for clarity.
Josh would like to construct a number pyramid such that the integer written in the topmost cell is (i.e. ). He wonders the following question: what is the lexicographically largest sequence of integers written in the bottom row of any such number pyramid? Formally, what is the lexicographically largest possible sequence ? Note that Josh cannot choose the values of and , and that all integers in the pyramid must be between and (inclusive).
Sequence is lexicographically larger than sequence if, for the smallest such that , .
Subtask 1 [10%]
Subtask 2 [20%]
Subtask 3 [30%]
Subtask 4 [40%]
No additional constraints.
The only line contains three space-separated integers, , , and respectively.
On a single line, output space-separated integers, representing the lexicographically largest possible sequence of integers written on row .
3 2 1
1 1 0
The optimal number pyramid is shown below.