Only one line, containing two integers nnn and BBB.
A total of BnB^nBn lines, each line is a base-BBB number, representing the ordering that meets the required conditions.
2 2
00 01 11 10
Thanks to @Night_Aurora for the SPJ.
Translated by ChatGPT 5
使用您的 清北信奥登峰计划 通用账户