n, m = map(int, input().split()) nums = list(map(int, input().split())) for i in range(0, n, m):print(*nums[i : i + m])