De Bruijn Sequence Junior
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
A de Bruijn cycle of order n for the set D = {0, 1, ..., b-1} is a cyclic sequence a_0, a_1, ..., a_l-1 such that every possible vector of length n over the set D appears exactly once in this sequence. This means that for any sequence b_0, b_1, ..., b_n-1 from D, there exists a unique index k ranging from 0 to l-1 such that b_j = a_(k+j) mod l for all j. Your task is to construct such a sequence.
Constraints
The integers n and b satisfy the conditions: 1 ≤ n ≤ 1000, 1 ≤ b ≤ 10, and b^n ≤ 10^4.
Input
The input consists of a single line containing the numbers n and b.
Output
Output the de Bruijn cycle of order n for the set of b-ary digits as a single line, without spaces.
Examples
Input #1
Answer #1
Submissions 6
Acceptance rate 67%