class GlobalMembers(object):

    N = 0

    M = 0

    arr = [0 for _ in range(10)]

    chk = [0 for _ in range(10)]


    @staticmethod

    def output(self):

        while i <= N:

            printf("%d ", arr[i])

        i += 1

        printf("\n")


    @staticmethod

    def dice1(self, step):

        if step > N:

            output()

            return


        for i in range(1, 7):

            arr[step] = i

            dice1(step + 1)


    @staticmethod

    def dice2(self, step):

        if step > N:

            output()

            return


        for i in range(arr[step - 1], 7):

            arr[step] = i

            dice2(step + 1)


    @staticmethod

    def dice3(self, step):

        if step > N:

            output()

            return


        for i in range(1, 7):

            if chk[i] != 0:

                continue

            chk[i] = 1

            arr[step] = i

            dice3(step + 1)

            chk[i] = 0


    @staticmethod

    def main():

        scanf("%d %d", N, M)

        arr[0] = 1

        if M == 1:

            dice1(1)

        elif M == 2:

            dice2(1)

        else:

            dice3(1)