import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n,h = na() w = n//h x = h while x % 2 == 0: x //= 2 if x != 1: h, w = w, h z = 0 ans = [[-1 for j in range(w)]for i in range(h)] for x in range(n-1,0,-1): if n % x: continue for i in range(x): ans[z//w][z%w] = x z += 1 for i in ans: print(*i)