#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; static const double EPS = 1e-8; static const double PI = 4.0 * atan(1.0); static const double PI2 = 8.0 * atan(1.0); #define REP(i,n) for(int i=0;i<(int)n;++i) #define ALL(c) (c).begin(),(c).end() #define CLEAR(v) memset(v,0,sizeof(v)) #define MP(a,b) make_pair((a),(b)) #define ABS(a) ((a)>0?(a):-(a)) #define FOR(i,s,n) for(int i=s;i<(int)n;++i) int N; char s[6][6]; int solve(int pat) { char t[6][6]; REP(i, N) REP(j, N) t[i][j] = s[i][j]; int mask = 1; FOR(i, 1, N) FOR(j, i + 1, N) { if (t[i][j] == '-') { t[i][j] = ((pat & mask) != 0) ? 'o' : 'x'; t[j][i] = (t[i][j] == 'o') ? 'x' : 'o'; } mask <<= 1; } pair win[6]; REP(i, N) { win[i].first = 0; win[i].second = i; } REP(i, N) REP(j, N) if (t[i][j] == 'o') ++win[i].first; sort(win, win + N); reverse(win, win + N); int r = 1; int rank[6]; REP(i, N) { if (i != 0 && win[i].first != win[i - 1].first) ++r; rank[win[i].second] = r; } return rank[0]; } int main(int argc, char **argv) { cin >> N; REP(i, N) REP(j, N) cin >> s[i][j]; REP(i, N) if (s[0][i] == '-') { s[0][i] = 'o'; s[i][0] = 'x'; } int res = solve(0); REP(i, (N - 2) * (N - 1) / 2) res = min(res, solve(i)); cout << res << endl; return 0; }