#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (106)
ll n;
bitset<MAXN> vis;
vector<int> v[MAXN];
int main() {
	FAST
	cin>>n;
	FOR(i,1,n) FOR(j,1,n) {
		char c; cin>>c;
		if(c=='1') {
			v[i].eb(j);
		}
	}
	ld ans = 0;
	FOR(i,1,n) {
		ll co = 0;
		function<void(ll)>dfs=[&](ll x){
			if(vis[x])return;
			vis[x]=1;
			for(auto i:v[x]) dfs(i);
		};
		FOR(j,1,n) {
			vis.reset();
			dfs(j);
			co += (int)vis[i];
		}
		FOR(j,0,n-1) {
			if(j>n-co) break;
			ld p = 1;
			FOR(k,0,j-1) {
				p *= ld(n-co-k) / ld(n-k);
			}
			p *= (ld)1 / (n-j);
			ans += p;
		}
	}
	cout<<setprecision(15)<<fixed<<ans<<'\n';
}

#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),i##z=(b);i<=i##z;i++)
#define ROF(i,a,b) for(int i=(a),i##z=(b);i>=i##z;i--)
#define temT template<typename T>
using namespace std;
typedef double ld;
const int N=int(1e2)+10;

int n; char f[N][N]; ld res;

void bbfs(int i){//back bfs
	static queue<int> que;
	static bool vis[N]; int tot=0;
	memset(vis,0,sizeof(vis));
	
	que.push(i),vis[i]=1,tot=1;
	while(que.size()){
		int u=que.front(); que.pop();
		FOR(v,1,n) if(f[v][u]=='1' && !vis[v])
			tot++,que.push(v),vis[v]=1;
	}
	
	res+=1.0/tot;
}

int main(){
	scanf("%d",&n);
	FOR(i,1,n) scanf("%s",f[i]+1);
	FOR(i,1,n) bbfs(i); 	
	printf("%.15lf",res);
	return 0;
} 