import numpy as np def solve(V: int, D: int): if D == 1: return np.ones((V, V), dtype=int) else: res = np.zeros((V, V), dtype=int) res[0, :] = 1 res[:, 0] = 1 return res res = solve(*map(int, input().split())) for x in res: print(*x)