P292: Enumeration of all $k$-ary Lyndon brackets of length $n$

P292: Enumeration of all $k$-ary Lyndon brackets of length $n$
Input:
Two integers $k$ and $n$.
Output:
All $k$-ary Lyndon brackets of length $n$.
Complexity:
$O(n)$ time per solution.
Comment:
Reference:
[Sawada2003] (Bibtex)