n,m = map(int,input().split(" ")) num = list(input().split(" ")) for i in range(n): print(" ".join(str(i) for i in num[m*i:m*(i+1)]))