V, D = map(int, input().split()) # Initialize adjacency matrix with all zeros E = [[0] * V for _ in range(V)] # Create a ring structure for i in range(V): j = (i + 1) % V E[i][j] = 1 E[j][i] = 1 # If V is even, add an additional edge to break bipartiteness if V % 2 == 0: E[0][2] = 1 E[2][0] = 1 # Print the adjacency matrix for row in E: print(''.join(map(str, row)))