求解答
from itertools import permutations n = int(input()) a = int(input()) init = input().strip().split() all = [] index = 0 for i in permutations(init): all.append(i) index += 1 if index > a: break for i in all[-1]: print(i,end=' ')