#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define debug(x) cerr<<#x<<" :"<<x<<"\n"
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false), cin.tie(), cout.tie()

typedef long long ll;
typedef long double ld;

const int maxn = 1e2 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;

vector<int> adj[maxn];
int mark[maxn];

double cnt = 0;

void dfs(int v)
{
	cnt++;
	mark[v] = true;
	for(int u : adj[v]) if(!mark[u]) dfs(u);
}

int32_t main()
{
    FAST;

	int n;
	cin >> n;

	for(int i=1;i<=n;i++)
	{
		string s;
		cin >> s;

		for(int j=0;j<n;j++) if(s[j] == '1') adj[j+1].pb(i);
	}

	double ans = 0;
	for(int i=1;i<=n;i++)
	{
		memset(mark, 0, sizeof(mark));
		cnt = 0;

		dfs(i);
		ans += (1.0/cnt);
	}

	cout << setprecision(15) << fixed << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=107;

char mp[N][N];
int Ans=0;

int main(){
	int n=input(),m=input();

	for(int i=1;i<=n;i++){
		scanf("%s",mp[i]+1);
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mp[i][j]=='.'){
				if(mp[i+1][j]=='.') Ans++;
				if(mp[i][j+1]=='.') Ans++;
			}
		}
	}

	printf("%d\n",Ans);
}