import sys

n, m = map(int, sys.stdin.readline().split())
data = [0 for _ in range(m)]


def pr(cur_index):
    if cur_index == m:
        compare = -1
        outData = []
        for i in range(m):
            if data[i] >= compare:
                outData.append(data[i])
                compare = data[i]
            else:
                break
        if len(outData) == m:
            for j in range(m):
                sys.stdout.write(str(outData[j])+" ")
            sys.stdout.write("\n")
        return
    for i in range(n):
        data[cur_index] = i + 1
        pr(cur_index + 1)


pr(0)
c195bc79f1f83ef25e6b2926095ef339d51dc50a
<mask token>


def pr(cur_index):
    if cur_index == m:
        compare = -1
        outData = []
        for i in range(m):
            if data[i] >= compare:
                outData.append(data[i])
                compare = data[i]
            else:
                break
        if len(outData) == m:
            for j in range(m):
                sys.stdout.write(str(outData[j]) + ' ')
            sys.stdout.write('\n')
        return
    for i in range(n):
        data[cur_index] = i + 1
        pr(cur_index + 1)


<mask token>

<mask token>


def pr(cur_index):
    if cur_index == m:
        compare = -1
        outData = []
        for i in range(m):
            if data[i] >= compare:
                outData.append(data[i])
                compare = data[i]
            else:
                break
        if len(outData) == m:
            for j in range(m):
                sys.stdout.write(str(outData[j]) + ' ')
            sys.stdout.write('\n')
        return
    for i in range(n):
        data[cur_index] = i + 1
        pr(cur_index + 1)


pr(0)

<mask token>
n, m = map(int, sys.stdin.readline().split())
data = [(0) for _ in range(m)]


def pr(cur_index):
    if cur_index == m:
        compare = -1
        outData = []
        for i in range(m):
            if data[i] >= compare:
                outData.append(data[i])
                compare = data[i]
            else:
                break
        if len(outData) == m:
            for j in range(m):
                sys.stdout.write(str(outData[j]) + ' ')
            sys.stdout.write('\n')
        return
    for i in range(n):
        data[cur_index] = i + 1
        pr(cur_index + 1)


pr(0)

import sys
n, m = map(int, sys.stdin.readline().split())
data = [(0) for _ in range(m)]


def pr(cur_index):
    if cur_index == m:
        compare = -1
        outData = []
        for i in range(m):
            if data[i] >= compare:
                outData.append(data[i])
                compare = data[i]
            else:
                break
        if len(outData) == m:
            for j in range(m):
                sys.stdout.write(str(outData[j]) + ' ')
            sys.stdout.write('\n')
        return
    for i in range(n):
        data[cur_index] = i + 1
        pr(cur_index + 1)


pr(0)

import sys

n, m = map(int, sys.stdin.readline().split())
data = [0 for _ in range(m)]


def pr(cur_index):
    if cur_index == m:
        compare = -1
        outData = []
        for i in range(m):
            if data[i] >= compare:
                outData.append(data[i])
                compare = data[i]
            else:
                break
        if len(outData) == m:
            for j in range(m):
                sys.stdout.write(str(outData[j])+" ")
            sys.stdout.write("\n")
        return
    for i in range(n):
        data[cur_index] = i + 1
        pr(cur_index + 1)


pr(0)