v, d = map(int, input().split()) e = [[0] * v for _ in range(v)] # k^d >= v k = 1 if d > 30: k = 2 else: while k ** d < v: k += 1 for i in range(v): s = k * i for j in range(k): nj = (s + j) % v e[i][nj] = 1 for t in e: for x in t: print(x, end='') print()