n = int(input()) s = [input().strip() for _ in range(n)] current_wins = [0] * n for i in range(n): for j in range(n): if i == j: continue if s[i][j] == 'o': current_wins[i] += 1 # Calculate team 0's maximum possible wins by winning all remaining matches remaining_0 = 0 for j in range(n): if j == 0: continue if s[0][j] == '-': remaining_0 += 1 max_wins0 = current_wins[0] + remaining_0 # Collect remaining matches between other teams (i, j where i < j and neither is 0) remaining_matches = [] for i in range(n): for j in range(i + 1, n): if i == 0 or j == 0: continue if s[i][j] == '-': remaining_matches.append((i, j)) m = len(remaining_matches) min_rank = float('inf') # Generate all possible outcomes for the remaining matches for mask in range(1 << m): wins = current_wins.copy() wins[0] = max_wins0 # Team 0's wins are fixed # Apply the current mask to determine outcomes of remaining matches for k in range(m): i, j = remaining_matches[k] if (mask >> k) & 1: wins[j] += 1 # j wins else: wins[i] += 1 # i wins # Calculate rank for team 0 sorted_wins = sorted(wins, reverse=True) rank = sorted_wins.index(wins[0]) + 1 if rank < min_rank: min_rank = rank print(min_rank)