P2328 [SCOI2005] Super Gray Code
Description

Input Format
Only one line, containing two integers $n$ and $B$.
Output Format
A total of $B^n$ lines, each line is a base-$B$ number, representing the ordering that meets the required conditions.
Explanation/Hint
Thanks to @Night_Aurora for the SPJ.
Translated by ChatGPT 5