# N과 M 8

import sys


def DFS(L, s):
    if L == m:
        for x in res:
            print(x, end=" ")
        print()
    else:
        for i in range(s, n):
            res.append(arr[i])
            DFS(L+1, i)
            res.pop()


n, m = map(int, sys.stdin.readline().rstrip().split())
arr = list(map(int, sys.stdin.readline().rstrip().split()))
arr.sort()
res = []
DFS(0, 0)
4ef355f01e22666ddb9171ea87bf793cebe4c0f4
<mask token>


def DFS(L, s):
    if L == m:
        for x in res:
            print(x, end=' ')
        print()
    else:
        for i in range(s, n):
            res.append(arr[i])
            DFS(L + 1, i)
            res.pop()


<mask token>

<mask token>


def DFS(L, s):
    if L == m:
        for x in res:
            print(x, end=' ')
        print()
    else:
        for i in range(s, n):
            res.append(arr[i])
            DFS(L + 1, i)
            res.pop()


<mask token>
arr.sort()
<mask token>
DFS(0, 0)

<mask token>


def DFS(L, s):
    if L == m:
        for x in res:
            print(x, end=' ')
        print()
    else:
        for i in range(s, n):
            res.append(arr[i])
            DFS(L + 1, i)
            res.pop()


n, m = map(int, sys.stdin.readline().rstrip().split())
arr = list(map(int, sys.stdin.readline().rstrip().split()))
arr.sort()
res = []
DFS(0, 0)

import sys


def DFS(L, s):
    if L == m:
        for x in res:
            print(x, end=' ')
        print()
    else:
        for i in range(s, n):
            res.append(arr[i])
            DFS(L + 1, i)
            res.pop()


n, m = map(int, sys.stdin.readline().rstrip().split())
arr = list(map(int, sys.stdin.readline().rstrip().split()))
arr.sort()
res = []
DFS(0, 0)

# N과 M 8

import sys


def DFS(L, s):
    if L == m:
        for x in res:
            print(x, end=" ")
        print()
    else:
        for i in range(s, n):
            res.append(arr[i])
            DFS(L+1, i)
            res.pop()


n, m = map(int, sys.stdin.readline().rstrip().split())
arr = list(map(int, sys.stdin.readline().rstrip().split()))
arr.sort()
res = []
DFS(0, 0)