중복 순열 문제.
import sys
n, m = map(int, sys.stdin.readline().rstrip().split())
numbers = list(map(int, sys.stdin.readline().rstrip().split()))
numbers.sort()
def DFS(permutation_list, start):
if len(permutation_list) == m:
print(*permutation_list, sep=' ')
return
for i in range(start, n):
permutation_list.append(numbers[i])
DFS(permutation_list, i)
permutation_list.pop()
DFS([], 0)