V, D = map(int, input().split()) # Initialize adjacency matrix with all zeros E = [[0] * V for _ in range(V)] # Connect each vertex i to i+1 to form a path for i in range(V - 1): E[i][i + 1] = 1 E[i + 1][i] = 1 # Add an edge between vertex 1 and 3 (0-based indices 0 and 2) if V >= 3 if V >= 3: E[0][2] = 1 E[2][0] = 1 # Print the matrix for row in E: print(''.join(map(str, row)))