def main(): team_count = int(input()) match_result_table = [list(input()) for _ in range(team_count)] best_rank = team_count for i in range(team_count): for j in range(i + 1, team_count): if match_result_table[i][j] == "-": match_result_table[i][j], match_result_table[j][i] = "o", "x" best_rank = min(best_rank, explore_match_outcomes(match_result_table, team_count)) match_result_table[i][j], match_result_table[j][i] = "x", "o" best_rank = min(best_rank, explore_match_outcomes(match_result_table, team_count)) match_result_table[i][j] = match_result_table[j][i] = "-" print(best_rank) return print(state_to_rank(match_result_table, team_count)) def explore_match_outcomes(match_result_table, team_count): for i in range(team_count): for j in range(i + 1, team_count): if match_result_table[i][j] == "-": return team_count return state_to_rank(match_result_table, team_count) def state_to_rank(match_result_table, team_count): win_count = [0] * team_count for i in range(team_count): for j in range(team_count): if i != j and match_result_table[i][j] == "o": win_count[i] += 1 sorted_unique_win_counts = sorted(set(win_count), reverse=True) return sorted_unique_win_counts.index(win_count[0]) + 1 if __name__ == "__main__": main()