while True:
    try:
        a, b = map(int, input().split())
        num = list(map(int, input().split()))
        count = 0
        while len(num):
            print(num.pop(0), end = ' ')
            count += 1
            if count == b:
                print()
                count = 0
    except:
        break