n, m = map(int, input().split()) l = list(map(int, input().split())) for i in range(n): l1 = l[0:m] l = l[m:] print(' '.join(map(str, l1)))