V, D = map(int, input().split()) # Initialize adjacency matrix with 0s (1-based indexing) E = [[0] * (V + 1) for _ in range(V + 1)] # Connect each node to its previous and next nodes in a circular manner for i in range(1, V + 1): prev = i - 1 if i > 1 else V next_node = i + 1 if i < V else 1 E[i][prev] = 1 E[i][next_node] = 1 E[prev][i] = 1 # Since the graph is undirected E[next_node][i] = 1 # For even V, add an additional edge to create an odd cycle if V % 2 == 0: mid = (V // 2) + 1 E[1][mid] = 1 E[mid][1] = 1 # Output the matrix (1-based to 0-based conversion for rows and columns) for i in range(1, V + 1): print(''.join(str(E[i][j]) for j in range(1, V + 1)))