#include #include #include using namespace std; #define RREP(i,s,e) for (i = e-1; i >= s; i--) #define rrep(i,n) RREP(i,0,n) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 1e8 typedef long long ll; int N; int win[6]; string s[6]; int dfs(int x, int y) { int nx = x + (y+1) / N; int ny = (y+1) % N; if (x == N) { int i, rank = 1; bool used[6] {}; REP (i,1,N) { if (!used[win[i]] && win[0] < win[i]) rank++; used[win[i]] = true; } return rank; } if (s[x][y] == '-') { int rank; win[x]++; s[x][y] = 'o'; s[y][x] = 'x'; rank = dfs(nx,ny); win[x]--; s[x][y] = 'x'; s[y][x] = 'o'; return min(rank,dfs(nx,ny)); } else if (s[x][y] == 'o') win[x]++; return dfs(nx,ny); } int main() { int i, j; cin >> N; rep (i,N) cin >> s[i]; rep (j,N) { if (s[0][j] == '-' || s[0][j] == 'o') { s[j][0] = 'x'; s[0][j] = 'o'; win[0]++; } } cout << dfs(1,0) << endl; return 0; }