De Bruijn Cycle High
Medium
Execution time limit is 1 second
Runtime memory usage limit is 256 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 from 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 following conditions: 1 ≤ n ≤ 1000, 1 ≤ b ≤ 10, and b^n ≤ 10^7.
Input
The input consists of a single line containing the integers n and b.
Output
Output the de Bruijn cycle of order n for the set of b-ary digits in a single line, without any spaces.
Examples
Input #1
Answer #1
Submissions 10
Acceptance rate 60%