v, d = map(int, input().split()) if d == 1: for _ in range(v): print("1 " * (v-1) + "1") else: print("1 " * (v-1) + "1") for _ in range(v-1): print("1" + " 0" * (v-1))