#include using namespace std; using pii = pair; int N; char B[10][10]; int h = 0; int ans = 100; void print() { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { printf("%c", B[i][j]); } puts(""); } } bool exist() { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (B[i][j] == '-') return true; } } return false; } int result() { map mp; for (int i = 0; i < N; i++) { mp[i] = 0; } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (B[i][j] == 'o') { mp[i]++; } } } set S; for (auto x:mp) { S.insert(x.second); } int cnt = 1; for (auto itr = S.rbegin(); itr != S.rend(); itr++) { if (*itr == mp[0]) { return cnt; } cnt++; } return 100; } void dfs() { if (!exist()) { // print(); // int res = result(); // printf("res: %d\n", res); // puts("---------------"); ans = min(ans, result()); } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (B[i][j] == '-') { B[i][j] = 'o'; B[j][i] = 'x'; dfs(); B[i][j] = 'x'; B[j][i] = 'o'; dfs(); B[i][j] = '-'; return; } } } } int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> B[i]; } for (int i = 0; i < N; i++) { if (B[0][i] == '-') { B[0][i] = 'o'; B[i][0] = 'x'; } } for (int i = 0; i < N; i++) { if (B[0][i] == '-') { B[0][i] = 'o'; B[i][0] = 'x'; } } dfs(); cout << ans << endl; return 0; }