num=input().split(" ")
n,m=map(int,num)
matrix_val=input().split(" ")
for i in range(n):
    for j in range(m):
        print(matrix_val[i*m+j],end=" ")
    print()