import sys input = sys.stdin.readline V,D=map(int,input().split()) E=[[0]*V for i in range(V)] if D==1: for i in range(V): for j in range(V): if i!=j: E[i][j]=1 else: for i in range(V): for j in range(V): if i==0 or j==0: E[i][j]=1 for ans in E: print("".join(map(str,ans)))