n, h = map(int, input().split()) P = {6: 3, 28: 7, 496: 31, 8128: 127} p = P[n] w = n // h R = [1] f = 2 while f * f <= n: if n % f == 0: R.append(f) if n // f != f: R.append(n // f) f += 1 R.sort() ANS = [[0 for _ in range(w)] for _ in range(h)] i = 0 if (n // p) % h == 0: for x in R: for j in range(x): ANS[i // w][i % w] = x i += 1 else: for x in R: for j in range(x): ANS[i % h][i // h] = x i += 1 for ans in ANS: print(*ans)