#include using namespace std; const int MAXN = 6; int N; string S[MAXN]; int win[MAXN]; int rank0() { for (int i = 0; i < N; i++) { win[i] = 0; } int win0 = 0; for (int i = 0; i < N; i++) { if (S[0][i] == 'o') { win0++; } } for (int i = 1; i < N; i++) { int w = 0; for (int j = 0; j < N; j++) { if (S[i][j] == 'o') { w++; } } win[w]++; } int rank = 1; for (int i = N - 1; i > win0; i--) { if (win[i] > 0) { rank++; } } return rank; } int best(int idx0, int idx1) { if (idx0 == N - 1) { return rank0(); } else if (idx1 == N) { return best(idx0 + 1, idx0 + 2); } else if (S[idx0][idx1] != '-') { return best(idx0, idx1 + 1); } else { int best_rank = N; S[idx0][idx1] = 'o'; S[idx1][idx0] = 'x'; best_rank = min(best_rank, best(idx0, idx1 + 1)); S[idx0][idx1] = 'x'; S[idx1][idx0] = 'o'; best_rank = min(best_rank, best(idx0, idx1 + 1)); S[idx0][idx1] = S[idx1][idx0] = '-'; return best_rank; } } int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> S[i]; } cout << best(0, 1); return 0; }