#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; #define all(x) (x).begin(),(x).end() #define PRI(n) cout << n < C(r + 1); C[0] = 1; FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD; return C[r]; } template class SegTree { int n; vector data; T def; function operation; function update; T _query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; if (a <= l && r <= b) return data[k]; else { T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); return operation(c1, c2); } } public: SegTree(size_t _n, T _def, function _operation, function _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } data = vector(2 * n - 1, def); } void change(int i, T x) { i += n - 1; data[i] = update(data[i], x); while (i > 0) { i = (i - 1) / 2; data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]); } } T query(int a, int b) { return _query(a, b, 0, 0, n); } T operator[](int i) { return data[i + n - 1]; } }; struct UnionFind { vector par; vector rank; UnionFind(int N) { for (int i = 0; i < N; ++i) { par.push_back(i); rank.push_back(0); } } int find(int x) { if (par[x] == x)return x; else return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y)return; if (rank[x] < rank[y])par[x] = y; else { par[y] = x; if (rank[x] == rank[y])rank[x]++; } } bool same(int x, int y) { return find(x) == find(y); } }; ll x, N; string S, s; int M[6][6]; int cnt[6]; char C[6][6]; int main() { cin >> N; vector> P; REP(i, N)REP(j, N) cin >> C[i][j]; REP(i, N) { FOR(j, i, N - 1) { char c = C[i][j]; if (c == '#')M[i][j] = -1; else if (i == 0 && c == '-')M[i][j] = 1; else if (c == '-') { P.push_back(make_pair(i, j)); M[i][j] = 2; } else if (c == 'o')M[i][j] = 1; else if (c == 'x')M[i][j] = 0; } } int ans = 6; for (int bit = 0; bit < (1 << P.size()); ++bit) { REP(i, N)REP(j, N) j >= i && M[i][j] == 1 ? cnt[i]++ : j >= i && M[i][j] == 0 ? cnt[j]++ : 0; REP(i, P.size()) { if (bit & (1 << i)) { cnt[P[i].first]++; } else { cnt[P[i].second]++; } } int tmp = 1, t = cnt[0]; sort(cnt,cnt+N); FOR (i, 1, N - 1) { if (t < cnt[i]) { t = cnt[i]; tmp++; } } PRI(tmp) ans = min(ans, tmp); REP(i, N)cnt[i] = 0; } PRI(ans) return 0; }