V, D = map(int, input().split()) # Initialize adjacency matrix with all zeros E = [[0]*V for _ in range(V)] # Create a triangle between nodes 0, 1, 2 (0-based) if V >= 3: E[0][1] = E[1][0] = 1 E[1][2] = E[2][1] = 1 E[2][0] = E[0][2] = 1 # Connect all other nodes to node 0 for i in range(3, V): E[0][i] = E[i][0] = 1 # Print the adjacency matrix for row in E: print(''.join(map(str, row)))