#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> neigh[105];
bool vis[105];
int cnt[105];

void dfs(int v)
{
	if (vis[v]) return;
	vis[v] = true;
	cnt[v]++;
	
	for (int u : neigh[v]) {
		dfs(u);
	}
}

long double fact[105];

long double C(int n, int m) {
	if (m > n) return 0;
	return fact[n] / fact[m] / fact[n - m];
}

long double f(int n, int m)
{
	long double res = 0;
	for (int i = 1; i <= n; i++) {
		res += C(n - i, m) * fact[m] * fact[n - m - 1];
	}
	res /= fact[n];
	return res;
}

int main()
{
	fact[0] = 1;
	for (int i = 1; i < 105; i++) {
		fact[i] = fact[i - 1] * i;
	}
	
	int n;
	ignore = scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		char s[105];
		ignore = scanf(" %s", s);
		for (int j = 0; j < n; j++) {
			if (s[j] == '1') {
				neigh[i].push_back(j);
			}
		}
	}
	
	for (int i = 0; i < n; i++) {
		memset(vis, 0, sizeof vis);
		dfs(i);
		cnt[i]--;
	}
	
	long double ans = 0;
	
	for (int i = 0; i < n; i++) {
		ans += f(n, cnt[i]);
	}
	
	printf("%.15Lf\n", ans);
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }

    double ans = 0;
    for (int i = 0; i < N; ++i) {
        vector<bool> used(N, false);
        queue<int> q;
        q.emplace(i);
        used[i] = true;
        while (!q.empty()) {
            int j = q.front();
            q.pop();
            for (int k = 0; k < N; ++k) {
                if (S[k][j] == '1' && used[k] == false) {
                    q.emplace(k);
                    used[k] = true;
                }
            }
        }
        int cnt = 0;
        for (auto e : used) {
            if (e) ++cnt;
        }

        ans += 1.0 / cnt;
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
}