/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//inline int read(){
//    int x=0;
//    char ch=getchar();
//    while(ch<'0'||ch>'9'){
//        ch=getchar();
//    }
//    while(ch>='0'&&ch<='9'){
//        x=(x<<1)+(x<<3)+(ch^48);
//        ch=getchar();
//    }
//    return x;
//}
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n;
string s[101];
bitset<101> reach[101];
int main(){
	cin>>n;
	rb(i,1,n)
		cin>>s[i];
	rb(i,1,n)
		rep(j,n)
			if(s[i][j]=='1')
				reach[j+1].set(i);
	rb(i,1,n)
		reach[i].set(i);
	rb(k,1,n)
		rb(i,1,n)
			rb(j,1,n)
				if(reach[i][j]){
					reach[i]|=reach[j];
				} 
	double rest=0.0;
	rb(i,1,n)
		rest+=1.0*n/(reach[i].count());
	printf("%.10f\n",rest/n);
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>> 
#define pqmin priority_queue <int,vector <int>,greater<int>> 
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define sp(x,y) fixed << setprecision(y) << x
#define out(r,x) cout<<"Case #"<<r<<": "<<x<<ee;
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define countdigit(x) floor(log10(x) +1)
#define M 1000000007
#define Z 998244353 
#define fill(arr,x) memset(arr,x,sizeof(arr))
//Use (k%M+m)%m always where k is any no
#define PI 3.1415926535
#define lcm(a,b)  a*b/(__gcd(a,b))
 typedef tree<int, null_type, less<int>, rb_tree_tag, 
 tree_order_statistics_node_update> pdbs; 
// // null for set,mapped_type for map; 
// //less for assending greater for descending
//ceil(a/b)=(a+b-1)/b
// v.si-1 can never be negative
#define ghadi() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
#define ee "\n"
#define re return 
 
 
//Author Rahul Sannigrahi
 
vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}
 
int power(int x,int y)
{
    int res=1;
    
    while(y>0)
    {
       if(y&1)
       res=((res%M)*(x%M))%M;
       
       y=y>>1;
       x=((x%M)*(x%M))%M;
    }
    re res;
} 
 
bool sortinrev(const pair<int,int> &a,  //desc of vp
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}
 
 
 
 
 
void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";   
    }
    cout<<ee;
}
 
int gk=1;
int ks=0;
 
int decode()
{
int i,j,k,l,n,m;
cin>>n>>k;
vi v;

f(i,0,n)
{
    cin>>l;
    v.pb(l);
}



// // show(v);
 vi pref(n+1,0);
 pref[1]=v[0]-1;
 f(i,2,n+1)
pref[i]=pref[i-1]+v[i-1]-v[i-2]-1;

// show(pref);/
f(j,0,k)
{
    cin>>m;
    
    if(m>pref[n])
    cout<<v[n-1]+m-pref[n]<<endl;
    else
    {
     int index;
    //  lower_bound(all(pref),m)-pref.begin();
    
    int r;
    l=0;r=n;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(pref[mid]-m>=0)
        {
            index=mid;
            r=mid-1;
        }
        else
        l=mid+1;
        
    }
     if(index==1)
     cout<<m<<ee;
     else 
     if(pref[index]==m)
     cout<<v[index-1]-1<<ee;
     else
     {
         cout<<v[index-2]+m-pref[index-1]<<ee;
     }
    }
}
   re 0;
}
 
 
 
int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif 
    
    int t=1;
    //   cin>>t;
    while(t--)
    {
      if (ks) 
        {
            cout << "Case #" << gk << ": "; 
         gk++;
        }
    decode();
    }
    return 0;
}