from copy import deepcopy N = int(input()) s = [list(input()) for _ in range(N)] P = [] for i in range(1,N): for j in range(i): P.append((i, j)) M = len(P) ans = 100 for bit in range(1<