#include<bits/stdc++.h>
#define ll long long
#define UKE kkk_shabi
#define luogu yyy
#define sumbit gugugu
#define tanao fAKeman
using namespace std;
const int maxn=55;
const int maxm=25;
int n,m,pre[1<<20],full;
char a[maxn][maxm];
double dp[1<<20],ans;
ll cnt[1<<20];
inline int read(){
	int res=0,f_f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f_f;
}
int main(){
	n=read();
	for (int i=1;~(n-i);i++) scanf("%s",a[i]+1),m=strlen(a[i]+1);
	if(n==0){printf("0\n");return 0;}
	full=(1<<m)-1;
	for (int mask=0;~(full-mask);mask++)
		for (int i=1;~(m-i);i++) if(mask&(1<<i-1)) pre[mask]++;
	for (int i=1;~(n-i);i++){
		for (int j=1;~(n-j);j++) if(i^j){
			int state=0;
			for (int k=1;~(m-k);k++)
				if(a[i][k]==a[j][k]) state|=(1LL<<k-1);
			cnt[state]|=(1LL<<i-1)|(1LL<<j-1);
		}
	}
	for (int mask=full;~mask;mask--)
		for (int i=1;~(m-i);i++)
			if(mask&(1LL<<i-1)) cnt[mask^(1LL<<i-1)]|=cnt[mask];
	dp[0]=1.0;
	for (int mask=0;~(full-mask);mask++){
		int sum=0;
		for (int i=1;~(n-i);i++) if(cnt[mask]&(1LL<<i-1)) sum++;
		ans+=dp[mask]*sum/n;
		for (int i=1;~(m-i);i++){
			if(mask&(1<<i-1)) continue;
			dp[mask|(1<<i-1)]+=dp[mask]/(m-pre[mask]);
		}
	}
	printf("%.10lf\n",ans);
	return 0;
}

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define LOG(x) cerr << #x << " = " << (x) << "\n"

typedef long long llint;
typedef pair<int,int> pii;
typedef long double ldouble;

int n, l;
char a[55][55];
llint masks[1<<20];
ldouble dp[1<<20];

inline int bc(llint x) {
  int ret = 0;
  for (int i = 0; i < n; ++i)
    ret += ((x & (1LL << i)) > 0);
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", a[i]);
    l = strlen(a[i]);
    for (int j = 0; j < i; ++j) {
      int mask = 0;
      for (int k = 0; k < l; ++k)
        mask |= ((a[i][k] == a[j][k]) << k);
      masks[mask] |= (1LL << i) | (1LL << j);
    }
  }

  for (int i = (1 << l)-1; i >= 0; --i) {
    for (int j = 0; j < l; ++j)
      if (i & (1 << j)) masks[i ^ (1 << j)] |= masks[i];
    int cnt = 0;
    for (int j = 0; j < l; ++j)
      if (!(i & (1 << j))) dp[i] += dp[i ^ (1 << j)], ++cnt;
    if (cnt > 0) dp[i] /= cnt;
    dp[i] += (ldouble)bc(masks[i]) / n;
  }

  printf("%.20lf\n", (double)dp[0]);
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[55][25];
int m,n,c[1<<20];
ll D[1<<20];
double f[1<<20],p[25],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%s",s[i]);
	m=strlen(s[1]);
	if(n==1)
	{
		puts("0.0");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int S=0;
			for(int k=0;k<m;k++)
				if(s[i][k]==s[j][k])S|=(1<<k);
			D[S]|=(1ll<<i)|(1ll<<j);
		}
	}
	for(int i=(1<<m)-1;i>=0;i--)
	{
		for(int j=0;j<m;j++)
		{
			if(((i>>j)&1))
			{
				D[i^(1<<j)]|=D[i];
			}
		}
		c[i]=n-__builtin_popcountll(D[i]);
	}
	f[0]=1;
	for(int i=0;i<(1<<m);i++)
	{
		int bt=__builtin_popcount(i),sum=n-c[i];
		double mv=f[i]/(m-bt);
		if(n==c[i])continue;
		for(int j=0;j<m;j++)
		{
			if((i>>j)&1)continue;
			int S=i|(1<<j);
			double a=1.0*(c[S]-c[i])/sum;
			f[S]+=mv*(1-a);
			p[bt+1]+=mv*a;
		}
	}
	for(int i=1;i<=m;i++)ans+=p[i]*i;
	printf("%.10lf\n",ans);
	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=22;
const int M=52;
int d[1<<N];
string s[M];
double per[N];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,len,msk;
	double ans=0;
	cin>>n;
	per[0]=1;
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	len=s[0].size();
	for(i=1;i<=len;i++){
		per[i]=per[i-1]/(len-i+1);
		if(i>1){
			per[i]*=(i-1);
		}
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			msk=0;
			for(k=0;k<len;k++){
				if(s[i][k]==s[j][k]){
					msk|=(1ll<<k);
				}
			}
			d[msk]|=(1ll<<i);
			d[msk]|=(1ll<<j);
		}
	}
	i=(1<<len); i--;
	for(i;i>-1;i--){
		for(j=0;j<len;j++){
			d[i]|=d[i|(1ll<<j)];
		}
	}
	for(i=0;i<(1<<len);i++){
		for(j=0;j<len;j++){
			if((i&(1ll<<j))){
				continue;
			}
			k=(d[i]^d[i|(1ll<<j)]);
			l=__builtin_popcountll(i|(1ll<<j));
			ans+=per[l]*l*__builtin_popcountll(k)/n;
		}
	}
	cout<<fixed<<setprecision(9)<<ans;
}

#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
using namespace std;

#define F cin
#define G cout

const int N = 51;
const int M = 21;

char s[N][M];
long long dp[1<<M]; // tin masti pe care nu le pot distinge
long double p[1<<M],ans;
int n,m;

int main()
{
    ios::sync_with_stdio(0);
    #ifndef ONLINE_JUDGE
        ifstream F("p.in");
    #endif

    F>>n;
    for (int i=0;i<n;++i)
        F>>s[i];
    m = strlen(s[0]);

    for (int i=0;i<n;++i)
        for (int j=i+1;j<n;++j)
        {
            int now = 0;
            for (int k=0;k<m;++k) // poz pe care sunt la fel
                now |= ( s[i][k] == s[j][k] ) << k;
            dp[now] |= (1LL<<i) | (1LL<<j); // i , j sunt la fel pe poz now
        }
    for (int i=(1<<m)-1;i>0;--i) //
        for (int k=0;k<m;++k)
            if ( i & (1<<k) )
               dp[i^(1<<k)] |= dp[i];
	p[0] = 1;
    for (int i=0;i<(1<<m);++i)
	{
		long double cnt = 0;
		for (int k=0;k<n;++k)
            cnt += (dp[i]>>k)&1;
		ans += p[i]*cnt;
		cnt = 0;
		for (int k=0;k<m;++k)
            cnt += (i>>k)&1;
		for (int k=0;k<m;++k)
            if(!(i&(1<<k)))
                p[i^(1<<k)] += p[i] / (m-cnt); // modificam pr de a ajunge in i^(1<<k)
	}
    ans /= double(n);
    G<<fixed<<setprecision(9)<<ans<<'\n';
}

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define lowbit(x) ((x)&-(x))
#define maxN 1100000
#define ll long long

using namespace std;

char s[50][21];
double ans;
ll m[maxN];
int length[maxN];
double f[maxN];
int N, len;

int main(){
	// init
	//freopen("t.in", "r", stdin);
	scanf("%d", &N);
	scanf(" ");
	for (int i = 0; i < N; ++i){
		gets(s[i]);
	}
	len = strlen(s[0]);

	rep(i,N) for (int j = i+1; j < N; ++j){
		ll S = 0;
		rep(k,len)
			S += (s[i][k] == s[j][k])<<k;
		m[S] |= (1LL<<i) | (1LL<<j);
	}

	for (int i = (1<<len)-1; i; --i){
		rep(j,len)
			if ((1<<j)&i)
				m[i^(1<<j)] |= m[i];
	}

	f[0] = 1;
	rep(i,(1<<len)){
		int cnt = 0;
		rep(j,N) cnt += (m[i]>>j)&1;
		ans += f[i] * cnt;
		rep(j,len)
			if (!((1<<j)&i)){
				f[i+(1<<j)] += f[i] / (len-length[i]) ;
				length[i+(1<<j)] = length[i] + 1;
			}
	}
	printf("%.9f\n", ans/N);
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <complex>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <string>
#include <cmath>
#include <ctime>
#include <queue>
#include <list>
#include <map>
#include <set>

#define all(x) (x).begin(), (x).end()
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

#ifdef KAZAR
    #define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
    #define eprintf(...) 0
#endif

using namespace std;

template<class T> inline void umax(T &a,T b){if(a<b) a = b ; }
template<class T> inline void umin(T &a,T b){if(a>b) a = b ; }
template<class T> inline T abs(T a){return a>0 ? a : -a;}
template<class T> inline T gcd(T a,T b){return __gcd(a, b);}
template<class T> inline T lcm(T a,T b){return a/gcd(a,b)*b;}

typedef long long ll;

const int inf = 1e9 + 143;
const ll longinf = 1e18 + 143;

inline int read(){int x;scanf(" %d",&x);return x;}

const int N = 55;
const int M = 20;

const double eps = 1e-13;

int n, m;
char s[N][M + 5];
ll bada[1 << M], badb[1 << M];
bool done[1 << M];
int kb[1 << M];

bool same(int i,int j,int mask){
    for(int x = 0; x < m; x++){
        if(mask & (1 << x)){
            if(s[i][x] != s[j][x])
                return false;
        }
    }
    return true;
}

double f[1 << M];

int all;

int main(){

#ifdef KAZAR
    freopen("f.input","r",stdin);
    freopen("f.output","w",stdout);
    freopen("error","w",stderr);
#endif

    srand(time(0));

    for(int i = 1; i < (1 << M); i++){
        kb[i] = kb[i - (i & -i)] + 1;
    }

    n = read();

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

    m = strlen(s[0]);

    all = (1 << m) - 1;

    int asz = m / 2;
    int bsz = m - m / 2;

    double res = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < (1 << m); j++)
            done[j] = 0;
        for(int mask = 0; mask < (1 << asz); mask++){
            bada[mask] = 0ll;
            for(int j = 0; j < n; j++){
                if(i != j && same(i, j, mask)){
                    bada[mask] |= 1ll << j;
                }
            }
        }
        for(int mask = 0; mask < (1 << bsz); mask++){
            badb[mask] = 0ll;
            for(int j = 0; j < n; j++){
                if(i != j && same(i, j, mask << asz)){
                    badb[mask] |= 1ll << j;
                }
            }
            for(int maska = 0; maska < (1 << asz); maska++){
                if((bada[maska] & badb[mask]) == 0ll){
                    done[(mask << asz) | maska] = 1;
                }
            }
        }
        f[0] = 1;
        for(int mask = 0; mask < (1 << m); mask++){
            if(done[mask]){
                res += f[mask] * kb[mask];
            }else if(f[mask] > eps){
                double coef = 1.0 / (m - kb[mask]);
                int x = all & ~mask;
                while(x > 0){
                    f[mask | (x & -x)] += f[mask] * coef;
                    x -= x & -x;
                }
            }
            f[mask] = 0;
        }
    }
    printf("%.10lf\n",res / n);

    return 0;
}

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

typedef long long LL;

const int MAXN = 50 + 5;
const int MAXM = 20;
LL identity[1<<MAXM];

int n;
char s[MAXN][MAXM + 10];

int main()
{
    scanf("%d", &n);
    getchar();
    //input
    for(int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    int len = strlen(s[0]);

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) { //枚举所有字符串的两两组合
            int mask = 0;           //mask表示一个确定的操作，比如 00101表示知道了第三位和第一位的字符
            for(int k = 0; k < len; k++) {
                if(s[i][k] == s[j][k]) {
                    mask |= (1<<k); //如果当前两个字符串该位相同，这将mask对应的位置1，最后mask表示通过当前操作无法区分这两个字符串。
                }
            }
            identity[mask] |= (1LL<<i)|(1LL<<j); //把i，j加进通过mask操作无法确定的字符串集合里，这里同样是状态压缩
        }
    }

    for(int mask = (1<<len) - 1; mask >= 0; mask--) {
        for(int i = 0; i < len; i++) {
            if((mask>>i)&1) { //这里是一个dp，通过这一步，
                              //dentity[mask]表示的就是所有通过mask操作均不能确定的字符串集合。（上面一步只是确定了刚好通过mask操作不能确定的集合
                identity[mask^(1<<i)] |= identity[mask]; //如果00110操作不能确定的字符串，很明显00100,00010操作也不能确定
            }
        }
    }

    //计算每一步操作能够确定的字符串的数量，进而计算出期望
    long double ans = 0;
    for(int mask = 0; mask < (1<<len); mask++) {
        int moves = __builtin_popcount(mask) + 1; //这里为什么+1下面解释
        for(int k = 0; k < len; k++) {
            if(!((mask>>k)&1)) { //如果mask的第k位为0
                LL dif = identity[mask]^identity[mask^(1<<k)]; //这里列子，如果00110不能确定a,b,c三个字符串，而00111不能确定a，b两个字符串，
                                                                //很明显可以得出c可以通过00111这个操作确定。这里通过异或就可以得出通过mask|k的操作可以确定的字符串
                                                                //所以上面的操作次数是 mask中的1的数量+1，因为还需要另外一步k
                if(dif == 0) continue;      //mask|k一个字符串都不能确定。
                int cnt = __builtin_popcountll(dif); //计算mask|k能确定的字符串数量
                long double curexp = cnt * moves; //因为现在算的是把所有字符串全部确定的期望，所以每一个字符串都需要moves次的操作
                for(int i = 0; i < moves - 1; i++) {
                    curexp *= (long double)(moves - i - 1) / (long double)(len - i); //操作数乘上当前操作发生的概率，P = {1/C_n^{moves-1}}*{1/n - (moves - 1)}
                }
                curexp /= (long double)(len - moves + 1); //依然是计算概率见上面的公式
                ans += curexp; //根据加法原理，当前操作的期望加到总的期望里面去
            }
        }
    }
    ans /= (long double)n; //通过上面操作ans计算出的是所有字符串需要的操作的期望之和，所以除以n才是一个字符串需要的操作数的期望。
    cout << fixed << setprecision(15) << ans << endl; //输出答案
}

#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cmath>
#include <complex>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <valarray>
#include <list>

using namespace std;

typedef long long ll;

const int MN = 52;

int n, m;
int cnt[1<<20];
double dp[1<<20];
bool used[1<<20];
double solve(int mp) {
    if (cnt[mp] == n) return 0;
    if (used[mp]) return dp[mp];
    used[mp] = true;
    int c = 0;
    double res = 0;
    for (int i = 0; i < m; i++) {
        if (mp & 1<<i) continue;
        c++;
        res += solve(mp | 1<<i);
    }
    return dp[mp] = res/c+(n-cnt[mp]);
}

int lastb[1<<20];

int main() {
    lastb[0] = -1;
    for (int i = 1; i < 1<<20; i++) {
        for (int j = 0; j < 20; j++) {
            if (i & 1<<j) {
                lastb[i] = j;
                break;
            }
        }
    }
    cin >> n;
    if (n == 1) {
        printf("0\n");
        return 0;
    }
    string s[MN];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    m = s[0].size();
    for (int i = 0; i < n; i++) {
        ll mp[20] = {};
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < n; k++) {
                if (s[k][j] == s[i][j]) {
                    mp[j] |= (1LL<<k);
                }
            }
        }
        vector<ll> dp(1<<m);
        dp[0] = (1LL<<n)-1;
        for (int j = 1; j < 1<<m; j++) {
            int k = lastb[j];
            dp[j] = dp[j & ~(1<<k)] & mp[k];
            if (dp[j] == 1LL<<i) {
                cnt[j] += 1;
            }
        }
    }
    printf("%.20f", solve(0)/n);
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <complex>
#include <ctime>
#include <iomanip>
#include <cassert>
#include <sstream>
#include <iterator>

using namespace std;

#define file "file"
#define mp make_pair
#define pb push_back
#define xx real()
#define yy imag()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<double> point;

const int MAXN = 50 + 5;
const int MAXL = 20 + 5;
const ll MASK = 1ll << 20;

char s[MAXN][MAXL];
ll dp[MASK];
ll res[MAXN];

int get_cnt(ll n){
	if(!n) return 0;
	else return 1 + get_cnt(n & (n - 1));
}

void solve(){
	int n;
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%s",s[i]);
	}
	int m = strlen(s[0]);
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			ll mask = 0;
			for(int k = 0;k < m;k++){
				if(s[i][k] == s[j][k]){
					mask |= (1ll << k);
				}
			}
			dp[mask] |= 1ll << i;
			dp[mask] |= 1ll << j;
		}
	}
	int b = 1 << m;
	for(int i = b - 1;i >= 0;i--){
		for(int j = 0;j < m;j++){
			if(i & (1 << j)){
				dp[i ^ (1 << j)] |= dp[i];
			}
		}
	}
	long double ans = 0;
	int cnt2 = 0,cnt = 0;
	for(int i = 0;i < b;i++){
		cnt = get_cnt(i);
		for(int j = 0;j < m;j++){
			if(i & (1 << j)){
				continue;
			}
			ll dif = dp[i] ^ dp[i ^ (1 << j)];
			if(dif == 0) continue;
			cnt2 = get_cnt(dif);
			res[cnt + 1] += cnt2;
		}
	}
	for(int i = 1;i <= m;i++){
		long double val = res[i];
		for(int j = 0;j < i;j++){
			val *= (1. * i - j) / (m - j);
		}
		ans += val;
	}
	ans /= n;
	printf("%.9lf",(double)ans);
}

int main()
{
	#ifndef ONLINE_JUDGE
    assert(freopen("input.txt","r",stdin));
    assert(freopen("output.txt","w",stdout));
    #else
    //assert(freopen(file".in","r",stdin)); assert(freopen(file".out","w",stdout));
    #endif
	int t = 1;
	while(t--){
		solve();
	}
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <ctime>

using namespace std;

const int N = 20;
const int M = 150;
int n;
char s[M][N + 10];

typedef long long li;
typedef long double ld;

li d[(1 << N)];

inline bool has(li mask, int pos) {
 	return (mask >> pos) & 1;
}

ld prob[N + 10];
ld totalGuessed[N + 10];

int main() {
 	int n;
 	scanf("%d", &n);

 	for(int i = 0; i < n; i++) {

 	 	scanf("%s", s[i]);
 	}

  int m = strlen(s[0]);

 	for(int i = 0; i < n; i++) {
 		for(int j = 0; j < n; j++) {
 		 	if (i == j) continue;

 		 	int same = 0;

 		 	for(int k = 0; k < m; k++) {
 		 	 	if (s[i][k] == s[j][k]) same |= (1 << k);
 		 	}

 		 	d[same] |= (1LL << i);
 		}
 	}

 	for(int mask = (1 << m) - 1; mask; mask--) {
 	 	for(int i = 0; i < m; i++) {
 	 		if (has(mask, i)) {
 	 			d[mask ^ (1 << i)] |= d[mask];
 	 	 	}
 	 	}
 	}

	long double ans = 0;

	for(int mask = 0; mask < (1 << m); mask++) {
		int moves = __builtin_popcount(mask) + 1;

    for(int i = 0; i < m; i++) {
	 	 	if (!has(mask, i)) {
				li res = d[mask] ^ d[mask ^ (1 << i)];
				if (res == 0) continue;

	 	 		int cntGuessed = __builtin_popcountll(res);

	 	 		totalGuessed[moves] += cntGuessed;
			}
	 	}
	}

	for(int i = 1; i <= m; i++) {
	 	ld val = totalGuessed[i] * i;

	 	for(int j = 0; j < i - 1; j++)
	 		val *= ld(i - 1 - j) / ld(m - j);

	 	ans += val / ld(m - i + 1);
	}

	ans /= ld(n);
	cerr << clock() << endl;
	cout << fixed << setprecision(15) << ans << endl;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <ctime>

using namespace std;

const int N = 20;
const int M = 150;
int n;
char s[M][N + 10];

typedef long long li;
typedef long double ld;

li d[(1 << N)];

inline bool has(li mask, int pos) {
    return (mask >> pos) & 1;
}

ld prob[N + 10];
ld totalGuessed[N + 10];

int main() {
    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) {

        scanf("%s", s[i]);
    }

  int m = strlen(s[0]);

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if (i == j) continue;

            int same = 0;

            for(int k = 0; k < m; k++) {
                if (s[i][k] == s[j][k]) same |= (1 << k);
            }

            d[same] |= (1LL << i);
        }
    }

    for(int mask = (1 << m) - 1; mask; mask--) {
        for(int i = 0; i < m; i++) {
            if (has(mask, i)) {
                d[mask ^ (1 << i)] |= d[mask];
            }
        }
    }

    long double ans = 0;

    for(int mask = 0; mask < (1 << m); mask++) {
        int moves = __builtin_popcount(mask) + 1;

    for(int i = 0; i < m; i++) {
            if (!has(mask, i)) {
                li res = d[mask] ^ d[mask ^ (1 << i)];
                if (res == 0) continue;

                int cntGuessed = __builtin_popcountll(res);

                totalGuessed[moves] += cntGuessed;
            }
        }
    }

    for(int i = 1; i <= m; i++) {
        ld val = totalGuessed[i] * i;
        //cout << totalGuessed[i] << endl;

        for(int j = 0; j < i - 1; j++)
            val *= ld(i - 1 - j) / ld(m - j);

        ans += val / ld(m - i + 1);
    }

    ans /= ld(n);
    cerr << clock() << endl;
    cout << fixed << setprecision(15) << ans << endl;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

/*int binom(int a, int b) {
	if (b==0 || b==a) return 1;
	return binom(a-1,b-1)+binom(a-1,b);
}*/

int binom[21][21];

ll nonUnique[(1 << 20)];
ll pow[51];

int main() {
	int n; cin >> n;
	vector<string> s;
	for (int i=0; i<n; i++) {
		string st; cin >> st;
		s.push_back(st);
	}
	int m; m = s[0].size();

	for (int i=0; i<=20; i++) for (int j=0; j<=i; j++) {
		if (j==0 || j==i) binom[i][j] = 1;
		else binom[i][j] = binom[i-1][j-1]+binom[i-1][j];
	}

	int P = (1 << m);
	double total = 0;

	for (int S=0; S<P; S++) nonUnique[S] = 0;
	pow[0] = 1;
	for (int i=1; i<=n; i++) {
		ll two = 2;
		pow[i] = two*pow[i-1];
	}

	for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) {
		int same = 0;
		for (int k=0; k<m; k++) if (s[i][k] == s[j][k]) {
			same += (1 << k);
		}
		nonUnique[same] |= pow[i];
		nonUnique[same] |= pow[j];
	}

	for (int S=P-1; S>=0; S--) {
		for (int k=0; k<m; k++) {
			int d = (1 << k);
			if ((S & d) == 0) {
				nonUnique[S] |= nonUnique[S+d];
			}
		}

		//printf("S=%d; nonUnique=%d.\n",S,nonUnique[S]);
	}

	ll lsum[21];
	for (int i=0; i<=m; i++) lsum[i]=0;
	for (int S=0; S<P; S++) {
		/*map<string,int> clusters;
		int sum = 0;
		for (int i=0; i<n; i++) {
			string st = "";
			for (int j=0; j<m; j++) {
				if ( ((1<<j) & S) == 0) continue;
				st += s[i][j];
			}
			if (clusters.count(st) == 0) {
				clusters.insert(pair<string,int>(st,1));
				sum++;
			} else {
				clusters[st]++;
				if (clusters[st] == 2) sum--;
			}
		}*/
		int l=0;
		for (int j=0; j<m; j++) if ( ((1<<j) & S) != 0) l++;

		ll sum = 0;
		for (int e=0; e<n; e++) {
			if ( !(nonUnique[S] & ((ll)1<<e)) != 0) sum++;
		}

		lsum[l] += sum;

		//printf("S=%d; l=%d; sum=%d; binom=%d\n",S,l,sum,binom[m][l]);

		//total += ( (double) sum ) / binom[m][l];
	}

	for (int l=0; l<=m; l++) total += ( (double) lsum[l] )/binom[m][l];

	double result =  ((double) (1+m)) - (total)/n;
	printf("%.12f\n",result);
}

#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <limits.h>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j123 = n; (i) < j123; (i) ++)
#define rep1(i, n) for (int (i) = 1, j123 = n; (i) <= j123; (i) ++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout << #a << " :";for(int i123=(x);i123<=(y);i123++) cout<<setw(4)<<(a)[i123];cout<<endl;}
#define clr(x) memset(x,0,sizeof(x));
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef long double ld;
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
// const ll MOD = ;

int N, M;
string s[100];
ll d[1<<20];
ld f[1<<20];
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0);
  cin >> N;
  rep(i,N) cin >> s[i];

  M = s[0].size();
  rep(i,N) rep(j,N) if (i!=j)
  {
    int same = 0;
    rep(k,M) if (s[i][k]==s[j][k]) same|=(1<<k);
    d[same]|=(1LL<<i);
  }
  for (int mask = (1<<M)-1; mask>=0; mask--)
    rep(i,M)
      if (!((mask>>i)&1))
        d[mask]|=d[mask|(1<<i)];

//  dba(d,0,(1<<M)-1);
  // how many more questions we will need to ask
  // to determine the string
  // assuming we have asked "mask" questions
  // and have not figured out which one.
  for (int mask = (1<<M)-1; mask >= 0; mask--)
  {
    if (d[mask]==0) continue;
    ld tot = 0;
    int cnt = 0;
    rep(i,M) if (!((mask>>i)&1))
    {
      cnt++;
      tot += f[mask|(1<<i)]*__builtin_popcountll(d[mask|(1<<i)]) / __builtin_popcountll(d[mask]);
    }
    tot /= cnt;
    tot += 1;
    f[mask]=tot;
  }
  cout << f[0] << endl;
}

#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <stack>
#include <queue>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <stdlib.h>
#define ll long long
using namespace std;

int n; char s[86][24]; double dp[1<<20]={0};
ll g[1<<20]={}; double f[24]={1};

int calc(ll x)
{
    int ans=0;
    for(;x;)
    {
        ans+=x%2;
        x>>=1;
    }
    return ans;
}

void init(int l,int n)
{
    double cur=1;
    for(int i=1;i<=l;i++)
    {
        cur=cur/(l-i+1)*i;
        f[i]=cur;
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%s",s[i]);
    int l=strlen(s[0]);
    init(l,n);
    double ans=0;

    g[0]=(1ll<<n)-1;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
        {
            int h=0;
            for(int k=0;k<l;k++)
                if(s[i][k]==s[j][k]) h|=(1<<k);
            g[h]|=(1ll<<i)|(1ll<<j);
        }

    for(int i=(1<<l)-1;i>=0;i--)
        for(int k=0;k<l;k++)
            if(i & (1<<k)) g[i^(1<<k)]|=g[i];

    dp[0]=1.0;
    for(int i=0;i<(1<<l);i++)
    {
        int x=calc(i),y=calc(g[i]);
        ans+=f[x]*y;
    }
    if(n==1) ans=0;
    printf("%.12lf\n",ans/n);
    return 0;
}

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
#define maxn 200005
long long mark[1<<21];
int cnt[1<<21];
double dp[1<<21];
int num[1<<21];
char s[55][22];
int f(long long x){
    int num=0;
    while(x>0){
        if(x&1) num++;
        x>>=1;
    }
    return num;
}
int main(){
    int n;
    memset(mark,0,sizeof(mark));
    memset(num,0,sizeof(num));
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%s",s[i]);
    int l=strlen(s[0]);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            int u=0;
            for(int k=0;k<l;k++){
                if(s[i][k]==s[j][k])
                    u|=(1<<k);
            }
            mark[u]|=1LL<<i;
        }
    }

    for(int i=(1<<l)-1;i>=0;i--){
        for(int j=0;j<l;j++){
            mark[i]|=mark[i|(1<<j)];
        }
    }
     memset(cnt,0,sizeof(cnt));
    for(int i=(1<<l)-1;i>=0;i--){
        cnt[i]=f(mark[i]);
        num[i]=f(i);
    }

    memset(dp,0,sizeof(dp));
    double ans=0;
    for(int i=(1<<l)-2;i>=0;i--){
        //cnt[i]=f(mark[i]);
        for(int j=0;j<l;j++){
            if(!((i>>j)&1)){
                dp[i]+=(dp[i|(1<<j)]);
            }
        }
        dp[i]=dp[i]/(l-num[i])+cnt[i]*1.0/n;
    }

    /*for(int mask=(1<<l)-2;mask>=0;mask--) {
        for(int y=0;y<l;y++) if((mask & (1<<y))==0) {
            dp[mask]+=dp[mask|(1<<y)];
        }
        dp[mask] = dp[mask]*1.0/(l-num[mask]) + cnt[mask]*1.0/n;
    }*/

    printf("%.10f\n",dp[0]);
}

#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef pair<LL, LL>    PLL;
typedef vector<int>     VI;
typedef vector<LL>      VL;
typedef vector<PII>     VPII;
typedef vector<VI>      VVI;
typedef vector<VPII>    VVPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	 cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define P2(x,y)	 cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define P3(x,y,z)cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"]"<<endl;
#define PP(x,i)	 cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define TM(a,b)	 cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << "\n"; cout.flush();}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 55;
const int M = 20;

int n, m;
string s[N];

LL bad[1 << M];

int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> s[i];
	m = s[0].length();

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++) {
			int eq = 0;
			for(int k = 0; k < m; k++) {
				if(s[i][k] == s[j][k]) eq |= 1 << k;
			}
			bad[eq] |= 1LL << i;
			bad[eq] |= 1LL << j;
		}

	for(int i = (1 << m) - 1; i >= 0; i--)
		for(int j = 0; j < m; j++)
			bad[i] |= bad[i | (1 << j)];

	double res = 0;
	for(int i = (1 << m) - 2; i >= 0; i--) {
		int one = bitset<30>(i).count();
		double num = 0;
		for(int j = 0; j < m; j++) {
			if((i >> j & 1) == 0) {
				num += bitset<N>(bad[i] ^ bad[i | (1 << j)]).count();
			}
		}
		for(int j = 1; j <= one; j++) num *= j;
		for(int j = m - one; j <= m; j++) num /= j;
		res += num * (one + 1);
	}
	res /= n;
	cout << fixed << setprecision(15) << res << endl;
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORd(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 60;
const int maxc = 30;
int n;
char s[maxn][maxc];
ll f[1 << 21];
ld g[1 << 21];

int popcount(ll k) {
	int res = 0;
	FOR(i, 0, maxn) if (k & 1LL << i) res++;
	return res;
}

void solve() {
	ms(s, 0); ms(f, 0); ms(g, 0);
	scanf("%d", &n);
	ld ans = 0;
	FOR(i, 0, n) scanf("%s", s + i);
	int len = strlen(s[0]);
	FOR(i, 0, n) FOR(j, i + 1, n) {
		int mask = 0;
		FOR(k, 0, len) if (s[i][k] == s[j][k]) mask |= 1 << k;
		f[mask] |= 1LL << i;
		f[mask] |= 1LL << j;
	}
	FORd(i, 1 << len, 0) FOR(j, 0, len) if (i & 1 << j) f[i ^ 1 << j] |= f[i];
	FOR(i, 0, 1 << len) f[i] = n - popcount(f[i]);
	g[0] = 1;
	FOR(i, 1, 1 << len) {
		int size = popcount(i);
		FOR(j, 0, len) if (i & 1 << j) {
			g[i] += g[i ^ 1 << j] / (len - size + 1);
			ans += 1.0 * (f[i] - f[i ^ 1 << j]) / n * size * g[i ^ 1 << j] / (len - size + 1);
		}
	}
	cout<<fixed<<setprecision(9)<<ans;
}

int main() {
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;

string s[51];
double dp[1050000];
int b[1050000];
long long bm[1050000];
int N, M;

void prep(){
    for(int i=0;i<(1<<M);++i)
        bm[i] = 0;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            int cur = 0;
            for(int k=0;k<M;++k){
                if(s[i][k] == s[j][k]){
                    cur |= 1<<k;
                }
            }
            bm[cur] |= 1LL<<i;
            bm[cur] |= 1LL<<j;
        }
    }
    for(int i=(1<<M)-1;i>=0;--i){
        for(int j=0;j<M;++j){
            bm[i & (~(1<<j))] |= bm[i];
        }
    }
    /*
    for(int i=0;i<(1<<M);++i){
        int tmp = bm[i];
        int cur = i;
        for(int j=0;j<M;++j){
            printf("%d", cur%2);
            cur/=2;
        }
        printf(" ");
        for(int j=0;j<N;++j){
            printf("%d", tmp%2);
            tmp/=2;
        }
        printf("\n");
    }
    */
}

double dp2[1050000];

int main(){
    cin >> N;
    for(int i=0;i<N;++i){
        cin >> s[i];
    }
    M = s[0].size();
    int lim = 1<<M;
    double prob = 1L / ((double) N);
    prep();
    b[0] = 0;
    for(int i=0;i<lim;++i){
        b[i] = b[i/2] + i%2;
    }
    double cnt, pr, p, tot;
    int tmp;
    long long cur;
    dp[lim-1] = 0;
    for(int i=lim-2;i>=0;--i){
        tot = 0;
        p = 1 / ((double)M - b[i]);
        dp[i] = 0;
        tot = (double)__builtin_popcount(bm[i]);
        tot += (double)__builtin_popcount(bm[i]>>32);
        if(bm[i] == 0){
            dp[i] = 0;
            continue;
        }
        for(int j=0;j<M;++j){
            if(!(i & (1<<j))){
                cnt = 0;
                cur = bm[i ^ (1<<j)] | ~bm[i];
                cur = ~cur;
                cnt = __builtin_popcount(cur);
                cnt += __builtin_popcount(cur>>32);
                pr = cnt/tot;
                //printf("%lf %lf %lf\n", cnt, tot, pr);
                dp[i] += ((dp[i ^ (1<<j)] + 1) * (1-pr) + (pr)) * p;
            }
        }
    }
    printf("%.12lf\n", dp[0]);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long int d[1101000];
string s[70];
void join(long long int x,long long int y)
{
    long long int same=0;
    for(long long int i=0;i<s[x].size();i++)
    {
        if(s[x][i]==s[y][i]) same|=(1LL<<i);
    }
    d[same]|=(1LL<<(int)x);
    d[same]|=(1LL<<(int)y);
    ////printf("%lld %lld %lld %lld\n",x,y,same,d[same]);
}
double gg[1100000];
bool check[1100000];
long long int n;
long long int __buidtin_popcount(long long int x)
{
    return __builtin_popcount(x>>32)+__builtin_popcount(x&((1LL<<32)-1));
}
double g(long long int mask)
{
    long long int sum=0,i;
    double ans=0;
    if(!d[mask])return 0;
    if(check[mask]) return gg[mask];
    for(i=0;i<n;i++)
    {
        if(mask&(1LL<<i)) continue;
        sum++;
    }
    for(i=0;i<n;i++)
    {
        if(mask&(1LL<<i)) continue;
        double tmp=((double)__buidtin_popcount(d[mask]^d[(mask|(1LL<<i))])/(double)__buidtin_popcount(d[mask]));
        ans+=((double)1/sum)*(((double)1-tmp)*g(mask|(1LL<<i))+tmp*__builtin_popcount((mask|(1LL<<i))));
        //printf("-- %lld %lld %lf %lld %lld %lld %lld %d\n",mask,i,ans,__buidtin_popcount(d[mask]),d[mask],mask|(1LL<<i),sum,__buidtin_popcount(d[mask]^d[(mask|(1LL<<i))]));
    }
    //printf("%lld %lf\n",mask,ans);
    check[mask]=true;
    return gg[mask]=ans;
}
int main()
{
    long long int i,j;
    long long int m;
    //freopen("test.inp","r",stdin);
    scanf("%lld",&m);
    for(i=0;i<m;i++)
    {
        cin>>s[i];
        for(j=0;j<i;j++)
        {
            join(i,j);
        }
    }
    n=(long long int )s[0].size();
    for(i=(1LL<<n)-1;i>=0;i--)
    {
        for(j=0;j<n;j++)
        {
            if(i&(1LL<<j)){
            d[i^(1LL<<j)]|=d[i];
            }
        }
       // //printf("%lld %lld\n",i,d[i]);
    }
    printf("%.9lf",g(0));
}

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define red(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define A first
#define B second
#define pb push_back
#define mk make_pair
#include <cstdlib>
#include <iomanip>
using namespace std;
const int N = 150;
const int M = 21;
const int inf = 1e9 + 7;
typedef long long ll;

ll d[1 << M];
int n, m;
char s[N][M];

long double L[M + 7];

bool has(ll mask, int i){
    return ((mask >> i) & 1);
}

inline int cnt(ll mask){
    int ans = 0;
    while (mask > 0){
        if (mask & 1) ans++;
        mask >>= 1;
    }
    return ans;
}

int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    rep(i, 0, n)
        scanf("%s", s[i]);
    m = strlen(s[0]);

    rep(i, 0, n)
        rep(j, 0, n){
            if (i == j) continue;
            ll same = 0;
            rep(t, 0, m)
                if (s[i][t] == s[j][t]) same |= (1 << t);
            d[same] |= (1LL << i);
            //d[same] |= (1LL << j);
        }
    red(mask, (1 << m) - 1, 0){
        rep(j, 0, m)
            if ((has(mask, j))){
                d[mask ^ (1 << j)] |= d[mask];
            }
    }

    rep(mask, 0, 1 << m){
        int move = cnt(mask) + 1;
        //cout<<move<<endl;
        rep(j, 0, m)
            if (!has(mask, j)){
                ll res = d[mask] ^ d[mask ^ (1 << j)];
                if (res == 0) continue;
                ll tmp = (ll) cnt(res);
                L[move] += tmp;
            }
    }

    long double res = 0;
    rep(i, 1, m + 1){
        long double val = L[i] * i;
        rep(j, 0, i - 1){
            val *= (long double) (i - j - 1) / (long double) (m - j);
        }
        res += val / (long double) (m - i + 1);
    }

    res /= (long double) n;
    //printf("%.9lf", res);
    //cout.setf(ios::basic_ios(15));
    cout<< fixed << std::setprecision(15) << res;

}

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn=1048577;

int n,m,s,sz,cnt;
double ans;
ll f[maxn],bin[55];
double dp[maxn];
char c[55][25];

int main(){
	bin[0]=1; for (int i=1;i<=50;i++) bin[i]=bin[i-1]<<1;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%s",c[i]+1);
	m=strlen(c[1]+1); sz=bin[m]-1;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++){
			s=0;
			for (int k=1;k<=m;k++)
				if (c[i][k]==c[j][k]) s|=bin[k-1];
			f[s]|=(bin[i-1]|bin[j-1]);
		}
	for (int i=sz;i>=0;i--)
		for (int j=0;j<m;j++)
			if (i&bin[j]) f[i^bin[j]]|=f[i];
	dp[0]=1;
	for (int i=0;i<=sz;i++){
		cnt=0;
		for (int j=0;j<m;j++)
			if (i&bin[j]) cnt++;
		for (int j=0;j<m;j++)
			if (!(i&bin[j])) dp[i|bin[j]]+=dp[i]/(double)(m-cnt);
		for (int j=0;j<n;j++)
			if (f[i]&bin[j]) ans+=dp[i];
	}
	printf("%.15f\n",ans/(double)n);
	return 0;
}

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

const int M=1048600;

int n,m,s,sz,cnt;
double ans;
ll bin[55],f[M];
double dp[M];
char c[55][25];

int main(){
	bin[0]=1; for (int i=1;i<=50;i++) bin[i]=bin[i-1]<<1;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%s",c[i]+1);
	m=strlen(c[1]+1); sz=bin[m]-1;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++){
			s=0;
			for (int k=1;k<=m;k++)
				if (c[i][k]==c[j][k]) s|=bin[k-1];
			f[s]|=(bin[i-1]|bin[j-1]);
		}
	for (int i=sz;i>=0;i--)
		for (int j=1;j<=m;j++)
			if (i&bin[j-1]) f[i^bin[j-1]]|=f[i];
	dp[0]=1;
	for (int i=0;i<=sz;i++){
		cnt=0;
		for (int j=1;j<=m;j++)
			if (i&bin[j-1]) cnt++;
		for (int j=1;j<=m;j++)
			if (!(i&bin[j-1])) dp[i|bin[j-1]]+=dp[i]/(m-cnt);
		for (int j=1;j<=n;j++)
			if (f[i]&bin[j-1]) ans+=dp[i];
	}
	printf("%.15f\n",ans/n);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

string S[100];
double dp[1100010];
long long vis[1100010];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> S[i];
    int m = S[0].size();

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int mask = 0;
            for (int k = 0; k < m; k++) {
                if (S[i][k] == S[j][k]) mask |= (1 << k);
            }
            vis[mask] |= (1LL << i) | (1LL << j);
        }
    }
    for (int i = (1 << m) - 1; i >= 0; i--) {
        for (int j = 0; j < m; j++) {
            if (i & (1 << j)) vis[i ^ (1 << j)] |= vis[i];
        }
    }
    for (int i = (1 << m) - 1; i >= 0; i--) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (i & (1 << j)) continue;
            dp[i] += dp[i ^ (1 << j)];
            cnt++;
        }
        if (cnt > 0) dp[i] /= cnt;
        dp[i] += __builtin_popcountll(vis[i]) / double(n);
    }
    printf("%.10f\n", dp[0]);
    return 0;
}

#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string& fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 55, D = 21;

int n;
string s[N];
LL poss[1 << D];
double f[1 << D];

int main() {
  srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      int mask = 0;
      for (int p = 0; p < s[i].length(); p++) {
        if (s[i][p] == s[j][p]) {
          mask |= 1LL << p;
        }
      }
      poss[mask] |= 1LL << i | 1LL << j;
    }
  }
  int len = (int)s[0].length();
  for (int i = (1 << len) - 1; i >= 0; i--) {
    for (int j = 0; j < len; j++) {
      if (~i >> j & 1) continue;
      poss[i ^ (1LL << j)] |= poss[i];
    }
  }
  for (int mask = (1 << len) - 1; mask >= 0; mask--) {
    int cnt = 0;
    if (!__builtin_popcountll(poss[mask])) continue;
    for (int i = 0; i < len; i++) {
      if (mask >> i & 1) continue;
      int nmask = mask | 1LL << i;
      f[mask] += f[nmask] * __builtin_popcountll(poss[nmask]) /
                     __builtin_popcountll(poss[mask]) +
                 1;
      ++cnt;
    }
    if (!cnt) continue;
    f[mask] /= cnt;
    // cerr << mask << ' ' << f[mask] << endl;
  }
  printf("%.10lf\n", f[0]);
  return 0;
}

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

int n, m;
long long d[1<<20];
int cnt[1<<20];
double dp[1<<20];

string s[50];

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    m = s[0].length();

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            long long msk = (1LL << i) + (1LL << j);

            int to = 0;
            for (int k = 0; k < m; k++) {
                if (s[i][k] == s[j][k]) {
                    to += (1 << k);
                }
            }

            d[to] |= msk;
        }
    }

    for (int msk = (1 << m) - 1; msk >= 0; msk--) {
        for (int k = 0; k < m; k++) {
            if (msk & (1 << k)) {
                d[msk ^ (1 << k)] |= d[msk];
            }
        }
        for (int k = 0; k < n; k++) {
            if (d[msk] & (1LL << k)) cnt[msk]++;
        }
    }

    for (int msk = (1 << m) - 1; msk >= 0; msk--) {
        if (!cnt[msk]) continue;
        int cc = 0;
        for (int i = 0; i < m; i++) {
            if (msk & (1 << i)) continue;
            cc++;
            dp[msk] += 1.0 + ((double) cnt[msk | (1 << i)] / (double) cnt[msk]) * dp[msk | (1 << i)];
        }
        dp[msk] /= (double) cc;
    }

    cout << setprecision(15) << fixed << dp[0] << endl;
}

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define INPUT freopen("draft.inp","r",stdin)
#define OUTPUT freopen("draft.out","w",stdout)
#define FOR(i,l,r) for(auto i=l;i<=r;i++)
#define REP(i,l,r) for(auto i=l;i<r;i++)
#define FORD(i,l,r) for(auto i=l;i>=r;i--)
#define REPD(i,l,r) for(auto i=l;i>r;i--)
#define ENDL printf("\n")
#define debug 1

typedef long long ll;
typedef pair<int,int> ii;

const int inf=1e9;
const int MOD=1e9+7;
const int N=60;

int a[N][20],n,m,cp[N],p[1<<20],key[2][1<<10][N];
char s[N];
long double f[1<<20];
vector <int> qc[N],q[N];
int cv(char s){
    if (s>='A'&&s<='Z') return s-'A';
    return 26+s-'a';
}
void solve(){
    f[0]=1;
    long double ans=0;
    int mid=m/2;
    ///split into 2 parts
    REP(bi,1,1<<mid){
        int last=bi^(bi&-bi),cur=__builtin_ffs(bi)-1;
        FOR(i,1,n) qc[key[0][last][i]].push_back(i);
        REP(i,0,n)
            while (!qc[i].empty()){
                int x=qc[i].back();qc[i].pop_back();
                q[a[x][cur]].push_back(x);
            }
        int top=0;
        for(int i=0;top<n;i++)
            while (!q[i].empty()) cp[++top]=q[i].back(),q[i].pop_back();
        for(int i=1,nkey=0;i<=top;i++,nkey++){
            int j=i;
            while (j<top&&key[0][last][cp[j+1]]==key[0][last][cp[i]]&&a[cp[j+1]][cur]==a[cp[i]][cur]) j++;
            FOR(i1,i,j) key[0][bi][cp[i1]]=nkey;
            i=j;
        }
    }
    ///
    REP(bi,1,1<<(m-mid)){
        int last=bi^(bi&-bi),cur=__builtin_ffs(bi)-1;
//        printf("%d %d %d\n",bi,last,cur);
        FOR(i,1,n) qc[key[1][last][i]].push_back(i);
        FOR(i,0,n)
            while (!qc[i].empty()){
                int x=qc[i].back();qc[i].pop_back();
                q[a[x][mid+cur]].push_back(x);
//                printf("%d %d\n",x,a[x][mid+cur]);
            }
        int top=0;
        for(int i=0;top<n;i++)
            while (!q[i].empty()) cp[++top]=q[i].back(),q[i].pop_back();
        for(int i=1,nkey=0;i<=top;i++,nkey++){
            int j=i;
            while (j<top&&key[1][last][cp[j+1]]==key[1][last][cp[i]]&&a[cp[j+1]][mid+cur]==a[cp[i]][mid+cur]) j++;
            FOR(i1,i,j) key[1][bi][cp[i1]]=nkey;
            i=j;
        }
//        FOR(i,1,n) printf("%d %d %d\n",bi,i,key[1][bi][i]);
    }
    ///merge back
    REP(bia,0,1<<mid)
        REP(bib,0,1<<(m-mid)){
            int idx=(bib<<mid)|bia;
            FOR(i,1,n) qc[key[1][bib][i]].push_back(i);
            FOR(i,0,n)
                while (!qc[i].empty()) q[key[0][bia][qc[i].back()]].push_back(qc[i].back()),qc[i].pop_back();
            for(int i=0,top=0;top<n;i++)
                while (!q[i].empty()) cp[++top]=q[i].back(),q[i].pop_back();
            FOR(i,1,n){
                int j=i;
                while (j<n&&key[0][bia][cp[j+1]]==key[0][bia][cp[i]]&&key[1][bib][cp[j+1]]==key[1][bib][cp[i]]) j++;
                p[idx]+=(j==i)?0:(j-i+1);
                i=j;
            }
        }
    REP(bit,1,1<<m){
        int c=__builtin_popcount(bit);
        for(int j=1;j<=bit;j<<=1) if (bit&j){
            int clast=bit^j;
            if (!p[clast]) continue;
            ans+=f[clast]*c*(p[clast]-p[bit])/(p[clast]*(m-c+1));
            f[bit]+=f[clast]*p[bit]/(p[clast]*(m-c+1));
        }
    }
//    REP(i,0,1<<m) printf("%d ",p[i]);ENDL;
//    REP(i,0,1<<m) printf("%.10f ",double(f[i]));ENDL;
    printf("%.10f",double(ans));
}
int main(){
//    INPUT;
    scanf("%d",&n);
    FOR(i,1,n) {
        scanf("\n%s",s);
        m=strlen(s);
        REP(j,0,m) a[i][j]=cv(s[j]);
    }
    solve();
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MAXN = 50 + 2;
const ll MAXL = 20;

ll n, len;
ll c[1<<MAXL];
string s[MAXN];
ll d[MAXN][MAXN];
ld ans;

int main(){
	cout << fixed << setprecision(15);
	cin >> n;
	for (ll i = 0; i < n; i++)	cin >> s[i];
	len = s[0].size();
	for (ll i = 0; i < n; i++)
		for (ll j = i + 1; j < n; j++){
			ll mask = 0;
			for (ll w = 0; w < len; w++)
				if (s[i][w] == s[j][w])	mask |= 1<<w;
			c[mask] |= 1LL<<j;
			c[mask] |= 1LL<<i;
		}

	for (ll i = (1<<len)-1; ~i; i--)
		for (ll j = 0; j < len; j++)
			if (((i >> j) & 1) == 0)
				c[i] |= c[i^(1<<j)];

	d[0][0] = 1;
	for (ll i = 1; i < MAXN; i++){
		d[i][i] = d[i][0] = 1;
		for (ll j = 1; j < i; j++)
			d[i][j] = d[i - 1][j] + d[i - 1][j - 1];
	}

	for (ll i = (1<<len)-1; ~i; i--){
		ll t = __builtin_popcountll(i);
		ll cnt = __builtin_popcountll(c[i]);
		ans += ld(cnt)/ n * ld(1./d[len][t]);
	}

	cout << ans << "\n";
	return 0;
}

#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
int n,len;
char s[55][25];
ll unable[1<<22];
double ans;
double f[1<<22];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%s",&s[i]);
	len=strlen(s[1]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			int temp=0;
			for(int k=0;k<len;k++)if(s[i][k]==s[j][k])temp|=(1<<k);
			unable[temp]|=((ll)1<<(i-1))|((ll)1<<(j-1));
		}
	for(int i=(1<<len)-1;i>=0;i--)
		for(int j=1;j<=len;j++)if(i&(1<<(j-1)))unable[i^(1<<(j-1))]|=unable[i];
	f[0]=1;
	for(int i=0;i<(1<<len);i++){
		int zero=0,one=0;
		for(int j=0;j<len;j++)if((i&(1<<j))==0)zero++;
		for(int j=0;j<n;j++)if(unable[i]&((ll)1<<j))one++;
		for(int j=0;j<len;j++)if((i&(1<<j))==0)f[i|(1<<j)]+=(f[i]/(double)zero);
		ans+=f[i]*(double)one;
	}
	printf("%.12lf\n",ans/(double)n);
	return 0;
}

/*
好难啊

f[i] 表示状态为i时距离确定的期望

*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
# define int long long
const int M = 55 ;
const int N = (1 << 20) + 5 ;
using namespace std ;
int m , n ;
char s[M][M] ;
int unf[N] , Num[N] ;
double f[N] ;
// unf[i] 表示状态为i时符合的串是那些
// num[i] 表示状态为i时能确定几个串
// f[i] 表示状态为i时期望再询问几次能确定是啥串
# undef int
int main() {
# define int long long
	scanf("%lld",&m) ;
	for(int i = 1 ; i <= m ; i ++) scanf("%s",s[i] + 1) ;
	n = strlen(s[1] + 1) ;
	for(int i = 1 ; i <= m ; i ++)
	    for(int j = i + 1 , sit ; j <= m ; j ++) {
	    	sit = 0 ;
	    	for(int k = 1 ; k <= n ; k ++)
	    	    if(s[i][k] == s[j][k])
	    	        sit |= (1LL << (k - 1)) ;
		    unf[sit] |= (1LL << (i - 1)) ;
			unf[sit] |= (1LL << (j - 1)) ;
		    // 求出i,j两个串在什么情况下无法分辨
		}
	for(int i = (1 << n) - 1 ; i >= 1 ; i --)
	    for(int j = 1 ; j <= n ; j ++)
	        if(i & (1 << (j - 1)))
	            unf[i ^ (1 << (j - 1))] |= unf[i] ;
	for(int i = 0 ; i < (1 << n) ; i ++)
	    for(int j = 1 ; j <= m ; j ++)
	        if(unf[i] & (1LL << (j - 1)))
			    Num[i] ++ ;
	for(int i = (1 << n) - 2 , tot ; i >= 0 ; i --) {
		if(!Num[i]) continue ;
		tot = n ;
		for(int j = 1 ; j <= n ; j ++)
		    if(i & (1 << (j - 1))) --tot ;
		for(int j = 1 ; j <= n ; j ++) {
			if(i & (1 << (j - 1))) continue ;
			f[i] += f[i | (1 << (j - 1))] / (double)tot * (double)Num[i | (1 << (j - 1))] / (double)Num[i] ;
		}
		f[i] += 1.0 ;
		/*
    设j = i | (1 << (j - 1)
    num[j] 一定不大于 num[i]
    因为是j向i转移不好考虑
	换成i向j转移思考,i有num[j]种选择可以变成j的样子
	但是有(num[i]-num[j])的选择是可以直接分辨出答案来的
	所以由j向i转移的时候就只需要考虑到那num[j]种情况,所以只有num[j]/num[i]的概率可以继续转移
	余下的(num[i]-num[j])/num[j]就是已经确定的那些
*/
	}
	printf("%.10lf\n",f[0]) ;
	return 0 ;
}

#include<bits/stdc++.h>
#define ll long long
#define jiaju zeiju
using namespace std;
const int maxn=55;
const int maxm=25;
int n,m,pre[1<<20],full;
char a[maxn][maxm];
double dp[1<<20],ans;
ll cnt[1<<20];
inline int read(){
	int res=0,f_f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f_f;
}
int main(){
	n=read();
	for (int i=1;~(n-i);i++) scanf("%s",a[i]+1),m=strlen(a[i]+1);
	if(n==0){printf("0\n");return 0;}
	full=(1<<m)-1;
	for (int mask=0;~(full-mask);mask++)
		for (int i=1;~(m-i);i++) if(mask&(1<<i-1)) pre[mask]++;
	for (int i=1;~(n-i);i++){
		for (int j=1;~(n-j);j++) if(i^j){
			int state=0;
			for (int k=1;~(m-k);k++)
				if(a[i][k]==a[j][k]) state|=(1LL<<k-1);
			cnt[state]|=(1LL<<i-1)|(1LL<<j-1);
		}
	}
	for (int mask=full;~mask;mask--)
		for (int i=1;~(m-i);i++)
			if(mask&(1LL<<i-1)) cnt[mask^(1LL<<i-1)]|=cnt[mask];
	dp[0]=1.0;
	for (int mask=0;~(full-mask);mask++){
		int sum=0;
		for (int i=1;~(n-i);i++) if(cnt[mask]&(1LL<<i-1)) sum++;
		ans+=dp[mask]*sum/n;
		for (int i=1;~(m-i);i++){
			if(mask&(1<<i-1)) continue;
			dp[mask|(1<<i-1)]+=dp[mask]/(m-pre[mask]);
		}
	}
	printf("%.10lf\n",ans);
	return 0;
}

/*
好难啊

f[i] 表示状态为i时距离确定的期望

*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
# define int long long
const int M = 55 ;
const int N = (1 << 20) + 5 ;
using namespace std ;
int m , n ;
char s[M][M] ;
int unf[N] , Num[N] ;
double f[N] ;
// unf[i] 表示状态为i时符合的串是那些
// num[i] 表示状态为i时能确定几个串
// f[i] 表示状态为i时期望再询问几次能确定是啥串
# undef int
int main() {
# define int long long
	scanf("%lld",&m) ;
	for(int i = 1 ; i <= m ; i ++) scanf("%s",s[i] + 1) ;
	n = strlen(s[1] + 1) ;
	for(int i = 1 ; i <= m ; i ++)
	    for(int j = i + 1 , sit ; j <= m ; j ++) {
	    	sit = 0 ;
	    	for(int k = 1 ; k <= n ; k ++)
	    	    if(s[i][k] == s[j][k])
	    	        sit |= (1LL << (k - 1)) ;
		    unf[sit] |= (1LL << (i - 1)) ;
			unf[sit] |= (1LL << (j - 1)) ;
		    // 求出i,j两个串在什么情况下无法分辨
		}
	for(int i = (1 << n) - 1 ; i >= 1 ; i --)
	    for(int j = 1 ; j <= n ; j ++)
	        if(i & (1 << (j - 1)))
	            unf[i ^ (1 << (j - 1))] |= unf[i] ;
	for(int i = 0 ; i < (1 << n) ; i ++)
	    for(int j = 1 ; j <= m ; j ++)
	        if(unf[i] & (1LL << (j - 1)))
			    Num[i] ++ ;
	for(int i = (1 << n) - 2 , tot ; i >= 0 ; i --) {
		if(!Num[i]) continue ;
		tot = n ;
		for(int j = 1 ; j <= n ; j ++)
		    if(i & (1 << (j - 1))) --tot ;
		for(int j = 1 ; j <= n ; j ++) {
			if(i & (1 << (j - 1))) continue ;
			f[i] += f[i | (1 << (j - 1))] / (double)tot * ((double)Num[i | (1 << (j - 1))] / (double)Num[i]) ;
		}
		f[i] += 1.0 ;
		/*
    设j = i | (1 << (j - 1)
    num[j] 一定不大于 num[i]
    因为是j向i转移不好考虑
	换成i向j转移思考,i有num[j]种选择可以变成j的样子
	但是有(num[i]-num[j])的选择是可以直接分辨出答案来的
	所以由j向i转移的时候就只需要考虑到那num[j]种情况,所以只有num[j]/num[i]的概率可以继续转移
	余下的(num[i]-num[j])/num[j]就是已经确定的那些
*/
	}
	printf("%.10lf\n",f[0]) ;
	return 0 ;
}

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <tuple>
#include <bitset>
#include <functional>

using namespace std;

typedef long long ll;

void Print()
{
    cout << endl;
}

template<typename T1, typename ... T>
void Print(const T1 &t1, const T& ... t)
{
    cout << t1 << " ";
    Print(t...);
}

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << "(" <<p.first << ", " << p.second << ")";
    return os;
}

const int N = 55, L = 20;
char str[N][L + 1];
int cmp[N][N];
double ans[N];
double dp[1 << L];
ll determine[1ll << L];

int n, m;

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> str[i];
    m = strlen(str[0]);

    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            for (int l = 0; l < m; ++l)
                if (str[i][l] == str[j][l]) cmp[j][i] = (cmp[i][j] |= (1 << l));
            determine[cmp[i][j]] |= 1ll << i;
            determine[cmp[i][j]] |= 1ll << j;
        }

    for (int ma = (1 << m) - 2; ma >= 0; --ma) {
        for (int i = 0; i < m; ++i)
            determine[ma] |= determine[ma | (1 << i)];
    }

    for (int ma = (1 << m) - 2; ma >= 0; --ma) {
        int cnt = 0; ll det = determine[ma];
        for (int i = 0; i < n; ++i)
            if (det & (1ll << i)) cnt += 1;

        dp[ma] = 0.0;
        int pos = 0;
        for (int l = 0; l < m; ++l) {
            if ((ma & (1 << l)) == 0)
            dp[ma] +=  dp[ma ^ (1 << l)], ++pos;
        }
        if (pos > 0) dp[ma] /= pos;
        dp[ma] += 1.0 * cnt / n;
    }

    printf("%.12f\n", dp[0]);

    return 0;
}

#include<fstream>
#include<iostream>
#include<cstdio>
#include<set>
#define FIT(a,b) for(vector<int>::iterator a=b.begin();a!=b.end();a++)
#include<stack>
#define ROF(a,b,c) for(register int a=b;a>=c;--a)
#include<vector>
#include<algorithm>
#define FOR(a,b,c) for(register int a=b;a<=c;++a)
#define REP(a,b) for(register int a=0;a<b;++a)
#include<cstring>
#include<bitset>
#include<cmath>
#include<iomanip>
#include<queue>
#define debug cerr<<"OK";
#define f cin
#define g cout
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define inf (1LL<<60)
#define eps 1.e-7
#define modu 1299379
#define modu2 1299541
#define confi (1<<20)+4
#define M 21
#define N 51
using namespace std;
/*ifstream f("a.in");
ofstream g("a.out");*/
/*int dx[]={0,0,0,1,-1};
int dy[]={0,1,-1,0,0};*/

const int kkt=1<<20;
char s[N][M+2];
int lim,n,m,nrb[1<<M];
double C[N][N],sol;
queue<int> q;
long long gud[1<<M];
int cou(long long x)
{
int so=0;
while(x)
{
    if(x&1)
        so++;
x>>=1;
}
return so;
}
int main ()
{
    #ifndef ONLINE_JUDGE
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    #endif

    f>>n;
    FOR(i,1,n)
    f>>(s[i]+1);
    m=strlen(s[1]+1);
    lim=1<<m;
    --lim;
    FOR(i,0,m)
    {
        C[i][0]=1;
        FOR(j,1,i)
        C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
    FOR(i,0,kkt)
        nrb[i]=nrb[i/2]+(i&1);
    FOR(i,1,n)
    {
        int bi=0;
        FOR(j,1,n)
        if(i!=j)
        {
            int mask=0;
            FOR(k,1,m)
            if(s[i][k]==s[j][k])
            mask+=1<<(k-1);
            gud[mask]|=(1LL<<i);
        }
    }
    ROF(i,lim,0)
    {
        for(int bit=1;bit<=lim;bit<<=1)
            if(!(i&bit))
                gud[i]|=gud[i^bit];
        if(!gud[i])
            continue;
        sol+=1.0*cou(gud[i])/n/C[m][nrb[i]];
    }
    g<<fixed<<setprecision(10)<<sol;
    return 0;
}
//Look at me! Look at me! The monster inside me has grown this big!

#include <cstdio>

using namespace std;

int CC;

int n, m;
char in[55][25];

int hash[(1 << 20)][50];
unsigned char safe[(1 << 20)];

bool bio[1 << 20];
double memo[1 << 20];
double dp(int bit){
       double &r = memo[bit];
       if (bio[bit]++) return r;

       int cnt = safe[bit];
       //for (int i = 0; i < n; ++i) if (safe[bit][i]) ++cnt;

       if (cnt == n) return 0;
       //printf("A");

       double F = (double)(n - cnt) / (double)n;
       int c2 = 0;

       for (int i = 0; i < m; ++i){
           if (bit & (1 << i)) continue;
           ++c2;
           r += dp(bit | (1 << i)) + F;
       }
       r /= c2;
       return r;
}

unsigned char M[1 << 25];
int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%s", in[i]);
    while (in[0][m] != '\0') ++m;

    CC = (1 << m) - 1;
    int xx = 1;
    for (int i = 0; i < m; ++i){
        for (int j = 0; j < n; ++j){
            hash[1 << i][j] = xx * in[j][i];
        }
        xx *= 101;
    }
    for (int i = 0; i <= CC; ++i){
        for (int t = 0; t < n; ++t){
            hash[i][t] = hash[i & -i][t] + hash[i - (i & -i)][t];
        }
    }
    for (int b = 0; b <= CC; ++b){
        for (int i = 0; i < n; ++i) ++M[hash[b][i] & ((1 << 25) - 1)];
        for (int i = 0; i < n; ++i){
            if (M[hash[b][i] & ((1 << 25) - 1)] == 1) ++safe[b];
            M[hash[b][i] & ((1 << 25) - 1)] = 0;
        }
    }

    printf("%.12lf\n", dp(0));

    return 0;
}

#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <ctime>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <list>
#include <deque>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define taskname "task_c"

const double pi = acos(-1.0);
const int size = 60;
const int ssize = 20;
const int lsize = 20 * 1000;

char field[size][size];
int n, m;
int cnt[1 << ssize];
double ans[1 << ssize];
int clr[size][size];
int hmas[lsize];

int bc(int msk) {
    int c = 0;
    while (msk > 0) {
        c += msk & 1;
        msk /= 2;
    }

    return c;
}

int h[size];
int ch[size];

void rec(int ps, int msk) {
    if (ps == m) {
        cnt[msk] = 0;
        for (int i = 0; i < n; i++)
            ch[i] = 0;
        for (int i = 0; i < n; i++) {
            if (ch[clr[ps][i]] > 0) {
                cnt[msk]++;
            }
            ch[clr[ps][i]]++;
            if (ch[clr[ps][i]] == 2)
                cnt[msk]++;
        }

        return;
    }

    for (int i = 0; i < n; i++)
        clr[ps + 1][i] = clr[ps][i];
    rec(ps + 1, msk);

    for (int i = 0; i < n; i++) {
        clr[ps + 1][i] = clr[ps][i] * 200 + (int) field[i][ps];
        hmas[clr[ps + 1][i]] = -1;
        //h[i] = clr[ps + 1][i];
    }
    //sort(h, h + n);
    int cc = 0;
    for (int i = 0; i < n; i++)
        {
        if (hmas[clr[ps + 1][i]] == -1) {
            hmas[clr[ps + 1][i]] = cc++;
        }
        clr[ps + 1][i] = hmas[clr[ps + 1][i]];
        }

    rec(ps + 1, msk | (1 << ps));
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", field[i]);
    }
    m = strlen(field[0]);

    for (int i = 0; i < n; i++)
        clr[0][i] = 0;
    rec(0, 0);

    for (int i = (1 << m) - 1; i >= 0; i--) {
        if (cnt[i] == 0)
            ans[i] = 0.0;
        else {
            ans[i] = 0.0;
            double p = 1.0 / (m - bc(i));
            for (int j = 0; j < m; j++)
                if (!((i >> j) & 1)) {
                    int tg = i | (1 << j);
                    double g = (cnt[i] - cnt[tg] + 0.0) / cnt[i];
                    ans[i] += p * (g + (1 - g) * (ans[tg] + 1));
                }
        }
    }

    cout.precision(20);
    cout << ans[0] << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef long long ll;

#define pb push_back

inline bool bit(int x, int b) {
  return (x >> b) & 1;
}

string s[60];
int n, m;
double prob[1 << 21];
ll not_can[1 << 21];

int main() {
  scanf("%d\n", &n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  m = s[0].size();

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if  (j == i) {
        continue;
      }
      int mask = 0;
      for (int k = 0; k < m; ++k) {
        if  (s[i][k] == s[j][k]) {
          mask |= 1 << k;
        }
      }
      not_can[mask] |= 1ll << i;
    }
  }

  for (int len = m; len >= 0; --len) {
    for (int mask = 0; mask < (1 << m); ++mask) {
      if  (__builtin_popcount(mask) == len) {
        for (int k = 0; k < m; ++k) {
          if  (bit(mask, k)) {
            not_can[mask ^ (1 << k)] |= not_can[mask];
          }
        }
      }
    }
  }

  double ans = 0.0;
  memset (prob, 0, sizeof prob);
  prob[0] = 1.0;
  for (int len = 0; len <= m; ++len) {
    for (int mask = 0; mask < (1 << m); ++mask) {
      if  (__builtin_popcount(mask) == len) {
        for (int k = 0; k < m; ++k) {
          if  (!bit(mask, k)) {
            double nprob = prob[mask] / (m - len);
            ll nmask = mask | (1 << k);
            int cnt_end = __builtin_popcountll(not_can[mask] ^ not_can[nmask]);
            ans += ((double) cnt_end / n) * nprob * (len + 1);
            prob[mask | (1 << k)] += nprob;
          }
        }
      }
    }
  }

  printf("%.10f\n", ans);
  return 0;
}

#include<bits/stdc++.h>

using namespace std;

// The codes which I use are taken from the book Competitive Programming 3 written by Steven Halim
// Shortcuts for "common" data types in contests
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define s(i) scanf("%d",&i)
#define sl(i) scanf("%ld",&i)
#define sll(i) scanf("%lld",&i)
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define NREP(i,a,b) \
for (int i = int(a); i >= int(b); i--)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion

int n , m , dp2[1 << 20];
ll submask[1 << 20];
string str[59];
double dp[1 << 20];

int calculate( int mask )
{
    if( dp2[mask]!= -1 )
        return dp2[mask];
    int cnt = 0;
    REP( i , 0 , n - 1 )
    {
        if( ( submask[mask] & ( 1ll << i ) ) )
            cnt++;
    }
    return dp2[mask] = cnt;
}

double memoize( int mask )
{
    if( mask == ( 1 << m ) - 1 )
        return 0.000;
    if( dp[mask] != -1 )
        return dp[mask];
    double ans = 0 ;
    int setb = __builtin_popcount( mask ) , xormask = ( ( 1 << m ) - 1 ) ^ mask , old = calculate( mask );
    while( xormask > 0 )
    {
        int temp = xormask & -xormask , nmask = ( mask | temp );
        ans +=  memoize( nmask ) +  ( double( calculate( nmask ) - old ) / ( n ) ) * ( setb + 1 )  ;
        xormask -= temp;
    }
    ans /= double( m - setb );
    return dp[mask] = ans;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    memset( dp2 , -1 , sizeof(dp2) ) ;
    s(n) ;
    REP( i , 0 , n - 1 )
        cin >> str[i];
    m = str[0].length();
    REP( i , 0 , n - 1 )
    {
        REP( j , i + 1 , n - 1 )
        {
            int mask = 0 ;
            REP( k , 0 , m - 1 )
            {
                if( str[i][k] == str[j][k] )
                    mask |= ( 1 << k );
            }
            submask[mask] |= ( ( 1ll << i ) | ( 1ll << j ) );
        }
    }
    REP( i , 0 , m - 1 )
    {
        NREP( j , ( 1 << m ) - 1 , 0 )
        {
            if( j & ( 1 << i ) )
                submask[j ^ ( 1 << i)] |= submask[j];
        }
    }
    REP( i , 0 , ( 1 << m ) - 1 )
        submask[i] ^= ( ( 1ll << n ) - 1 );
    REP( j , 0 ,( 1 << m ) - 1 )
        dp[j] = -1.000;
    double ans = memoize( 0 );
    printf("%0.12lf\n",ans);
    return 0;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
//#define ld long double
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;
typedef long double ld;
bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    a-=b;
    if(a<0)a+=mod;
    return a%mod;
}
struct CustomCompare
{
    bool operator()(ll a,ll b)
    {
        return a>b;
    }
};
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/
const int mxn = 22;
ll dp[(1LL<<mxn)];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);

ll n;cin>>n;
vector<string>s(n);
rep(i,0,n)cin>>s[i];
ll m = s[0].size();
vector<ld> cnt(m+1);
ld ans = 0.0;
rep(i,0,n)
{
    rep(j,0,n)
    {
        if(i==j)continue;
        ll mask = 0;
        rep(k,0,m)
        {
            if(s[i][k]==s[j][k])mask|=(1LL<<k);
        }
        dp[mask]|=(1LL<<i);
    }
}
//rep(i,0,(1LL<<m))cout<<dp[i]<<endl;
for(ll mask = (1LL<<m)-1;mask;mask--)
{
    rep(bit,0,m)
    {
        if(((mask>>bit)&1))dp[(mask^(1LL<<bit))]|=dp[mask];
    }
}

for(ll mask = 0;mask<(1LL<<m);mask++)
{
    ll q = __builtin_popcountll(mask) +1;
    //cout<<q<<endl;
    rep(bit,0,m)
    {
        if(!((mask>>bit)&1))
        {
            ll val = dp[mask]^dp[(mask^(1LL<<bit))];
            //cout<<val<<endl;
            if(val==0)continue;
            ll res = __builtin_popcountll(val);
            cnt[q]+=res;
        }
    }
}

for(ll q = 1;q<=m;q++)
{
    ld val = cnt[q]*q;

    rep(j,0,q-1)val*=ld(q-j-1)/ld(m-j);
    ans += val/ld(m-q+1);
}
ans/=ld(n);
cout<<fixed<<setprecision(15)<<ans<<endl;
return 0;
}
/*
1
3 1
023l
2 3
*/

#include <bits/stdc++.h>

using namespace std;

#define fin stdin
#define fout stdout
//FILE *fin = fopen("x.in", "r"), *fout = fopen("x.out", "w");

typedef long long i64;
typedef unsigned int i16;

const int nmax = 50;
const int lmax = 20;

int n, m;
double p[lmax + 1];
bitset<nmax + 1> unic[1 << lmax];

char s[nmax + 1][lmax + 1];

int main() {
    fscanf(fin, "%d", &n);

    for (int i = 0; i < n; ++ i)
        fscanf(fin, "%s", s[ i ]);

    m = strlen(s[ 0 ]);

    for (int i = 0; i < n; ++ i) {
        for (int j = i + 1; j < n; ++ j) {
            int st = 0;
            for (int k = 0; k < m; ++ k)
                if (s[ i ][ k ] == s[ j ][ k ])
                    st += (1 << k);

            unic[ st ][ i ] = unic[ st ][ j ] = 1;
        }
    }

    for (int i = (1 << m) - 2; i >= 0; -- i) {
        for (int j = 0; j < m; ++ j) {
            if ((i & (1 << j)) == 0)
                unic[ i ] |= unic[i + (1 << j)];
        }
    }

    for (int i = 0; i < (1 << m); ++ i)
        for (int j = 0; j < m; ++ j)
            unic[ i ][ j ] = !unic[ i ][ j ];

    p[ 0 ] = 1;
    for (int i = 1; i <= m; ++ i) {
        p[ i ] = p[i - 1] * i / (m - i + 1);
    }

    double ans = 0;
    for (int i = 0; i < (1 << m) - 1; ++ i) {
        int zerouri = 0;
        for (int j = 0; j < m; ++ j) {
            if ((i & (1 << j)) == 0) {
                ++ zerouri;
            }
        }

        for (int j = 0; j < m; ++ j) {
            if ((i & (1 << j)) == 0) {
                ans += (unic[i + (1 << j)] ^ unic[ i ]).count() * (m - zerouri + 1) * p[m - zerouri] / zerouri / n;
            }
        }
    }

    fprintf(fout, "%.12lf\n", ans);
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

const int MAXN = 55, MAXM = 20, POWM = (1 << MAXM), P = 131;
unsigned int hash[POWM][MAXN], a[MAXN];
int lb[POWM];
double dp[POWM];
string s[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(20);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> s[i];
    int m = s[0].length();
    for(int i = 1; i < (1 << m); i++)
        for(int j = 0; j < m; j++)
            if(i & (1 << j)) {
                lb[i] = j;
                break;
            }
    for(int i = 1; i < (1 << m); i++)
        for(int j = 0; j < n; j++)
            hash[i][j] = hash[i & ~(1 << lb[i])][j] * P + s[j][lb[i]];
    for(int i = 0; i < (1 << m); i++) {
        for(int j = 0; j < n; j++)
            a[j] = hash[((1 << m) - 1) & ~i][j];
        sort(a, a + n);
        int cnt = 0;
        for(int j = 0; j < n; j++)
            if((!j || a[j] != a[j - 1]) && (j + 1 >= n || a[j] != a[j + 1]))
                cnt++;
        if(cnt == n)
            continue;
        for(int j = 0; j < m; j++)
            if(i & (1 << j))
                dp[i] += dp[i & ~(1 << j)];
        dp[i] *= ((double)n / (n - cnt)) / __builtin_popcount(i);
        dp[i] += 1;
        dp[i] *= (double)(n - cnt) / n;
    }
    cout << dp[(1 << m) - 1] << '\n';
    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;

string s[51];
double dp[1050000];
int b[1050000];
long long bm[1050000];
int N, M;

void prep(){
    for(int i=0;i<(1<<M);++i)
        bm[i] = 0;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            int cur = 0;
            for(int k=0;k<M;++k){
                if(s[i][k] == s[j][k]){
                    cur |= 1<<k;
                }
            }
            bm[cur] |= 1LL<<i;
            bm[cur] |= 1LL<<j;
        }
    }
    for(int i=(1<<M)-1;i>=0;--i){
        for(int j=0;j<M;++j){
            bm[i & (~(1<<j))] |= bm[i];
        }
    }
}

int main(){
    cin >> N;
    for(int i=0;i<N;++i){
        cin >> s[i];
    }
    M = s[0].size();
    int lim = 1<<M;
    prep();
    b[0] = 0;
    for(int i=0;i<lim;++i){
        b[i] = b[i/2] + i%2;
    }
    double cnt, prob, p, tot;
    long long cur;
    dp[lim-1] = 0;
    for(int i=lim-2;i>=0;--i){
        tot = 0;
        p = 1 / ((double)M - b[i]);
        dp[i] = 0;
        tot = (double)__builtin_popcount(bm[i]);
        tot += (double)__builtin_popcount(bm[i]>>32);
        if(bm[i] == 0){
            dp[i] = 0;
            continue;
        }
        for(int j=0;j<M;++j){
            if(!(i & (1<<j))){
                cnt = 0;
                cur = bm[i ^ (1<<j)] | ~bm[i];
                cur = ~cur;
                cnt = __builtin_popcount(cur);
                cnt += __builtin_popcount(cur>>32);
                prob = cnt/tot;
                dp[i] += ((dp[i ^ (1<<j)] + 1) * (1-prob) + prob) * p;
            }
        }
    }
    printf("%.12lf\n", dp[0]);
    return 0;
}

#include <cstdio>
#include <cstring>
#define DB double
#define LL long long
#define one(x) (1ll<<x)
#define down(i,j,k) for (i=j;i>=k;i--)
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=50,M=21;
int n,len,i,j,k,cur,empty,stateN;
char st[N][M];
LL f[1<<20]; DB ans,P[1<<20];
void File()
{
	freopen("482C.in","r",stdin);
	freopen("482C.out","w",stdout);
}
int main()
{
//	File();
	scanf("%d",&n);
	rep(i,0,n-1) scanf("%s",st[i]);
	len=strlen(st[0]);
	rep(i,0,n-1)
	  rep(j,i+1,n-1) //对于每一对字符串，求出最大的匹配情况
	  {
	    	cur=0;
	    	rep(k,0,len-1)
	    	  if (st[i][k]==st[j][k]) cur|=one(k);
	    	f[cur]|=one(j); f[cur]|=one(i);
	  }
	stateN=(1<<len)-1;
	down(cur,stateN,1)
	  rep(j,0,len-1)
	    if (cur&one(j)) //一定要这一个地方有才能转移.
		  f[cur^one(j)]|=f[cur]; //把包含的子情况都推出来

	P[0]=1.0;
	rep(cur,0,stateN)
	{
		empty=len;
		rep(j,0,len-1)
		  if (cur&one(j)) empty--;
		rep(j,0,len-1)
		  if (!(cur&one(j)))
		    P[cur|one(j)]+=P[cur]/empty;
	}
	rep(cur,0,stateN)
	  rep(j,0,n-1)
	    if (f[cur]&one(j)) ans+=P[cur]; //还要乘上1/n才得到字符串是j的概率，为了优化常数放到最后一起乘
	printf("%.12lf\n",ans/n);
	return 0;
}
/*
   这一题坑爹般地告诉我，字符串数组一定要多开一位，否则自动连成一串！
   还坑爹般地告诉我，不要忽略1<<x后爆int的情况！！！
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 51, M = 21;
char s[N][M];
LL a[1 << M];
double f[1 << M];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%s", s[i]);
    int l = strlen(s[0]);
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            LL t = 0;
            for (int k = 0; k < l; ++k)
                t |= (s[i][k] == s[j][k]) << k;
            a[t] |= (1ll << i) | (1ll << j);
        }
    for (int i = (1 << l) - 1; i >= 0; --i)
        for (int j = 0; j < l; ++j)
            if (i >> j & 1) a[i ^ (1 << j)] |= a[i];
    f[0] = 1;
    double ans = 0;
    for (int i = 0; i < 1 << l; ++i) {
        int x = __builtin_popcount(i);
        for (int j = 0; j < l; ++j)
            if (!(i >> j & 1))  f[i | (1 << j)] += f[i] / (l - x);
        for (int j = 0; j < n; ++j)
            if (a[i] >> j & 1ll)    ans += f[i];
    }
    printf("%.10lf\n", ans / n);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define MAX 100005

const int maxn=1100000;

int n;
char s[60][25];
double dp[maxn];
ll u[maxn];
ll bit[60]={1};
int cnt[maxn];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	if(n==1){printf("%.9f\n",0.0);return 0;}
	for(int i=1;i<=52;i++)bit[i]=bit[i-1]<<1;
	int len=strlen(s[0]);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
				ll a=0;
				for(int k=0;k<len;k++)
					if(s[i][k]==s[j][k])a|=bit[k];
				u[a]|=(1LL<<i)|(1LL<<j);//�����⼸λ�Ժ����ļ������޷��ж�
		}
	}
	for(int i=bit[len]-1;i>=1;i--)
	{
		for(int j=0;j<len;j++)
		{
			if(i&bit[j]) u[i^bit[j]]|=u[i];
		}
	}
	for(int i=0;i<=bit[len]-1;i++)
		for(int j=0;j<n;j++)
			if(u[i]&(1LL<<j))cnt[i]++;//�жϹ���Щλ���Ժ�
	dp[bit[len]-1]=0;
	for(int i=bit[len]-2;i>=0;i--)
	{
		if(cnt[i]==0){dp[i]=0;continue;}
		int c=len;
		for(int j=0;j<len;j++)if(i&bit[j])c--;
		for(int j=0;j<len;j++)
		{
			if(i&bit[j])continue;
			dp[i]+=dp[i|bit[j]]*1.0/c*cnt[i|bit[j]]/cnt[i];
		}
		dp[i]++;
	}
	printf("%.9f\n",dp[0]);
	return 0;

}

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 50 + 5, B = 20, MASK = (1 << B) + 20;
int n, m;
string s[N];
ll d[MASK];
ld dp[MASK], ans;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> s[i];
  m = s[0].size();

  for (int i = 0; i < n; i ++){
    for (int j = 0; j < i; j ++){
      int mask = 0;
      for (int k = 0; k < m; k ++)
	if (s[i][k] == s[j][k]) mask |= (1 << k);

      d[mask] |= (1LL << i) | (1LL << j);
    }
  }

  for (int mask = (1 << m) - 1; mask >= 0; mask --)
    for (int i = 0; i < m; i ++)
      if (mask >> i & 1) d[mask ^ (1 << i)] |= d[mask];

  dp[0] = 1;
  for (int mask = 0; mask < (1 << m); mask ++){
    int k = __builtin_popcount(mask);
    for (int i = 0; i < m; i ++){
      if (mask >> i & 1) continue;

      ld p = 1.0 / (m - k) * dp[mask];
      dp[mask | (1 << i)] += p;
      ans += p * (k + 1) * __builtin_popcountll(d[mask] ^ d[mask | (1 << i)]) / n;
    }
  }

  cout << fixed << setprecision(15) << ans << '\n';
}

#include <string>
#include <vector>
#include <bits/stdc++.h>

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;

const int M = 20, N = 50;
ld d[1 << M];
int dif[1 << M];
string s[N];

int n = 50, m=20;
char T[(1<<M)][N];

int tt[N*1000];
int qq[N*1000];
int vv[N*1000];

void g(int msk)
{
    if (dif[msk] != -1) return;
    int pos = -1;
    ford (i, m)
    if ((1 << i) & msk)
    {
        pos = i;
        break;
    }
    dif[msk] = 0;
    if (pos != -1){
       int z = msk ^ (1 << pos);
       vector<pii> w(n);
       forn (i, n) tt[i] = T[z][i] * 300 + s[i][pos];
        int c = 0;
        forn (i, n) {
            if (!qq[tt[i]]) {dif[msk]++; vv[tt[i]] = c++;}
            if (qq[tt[i]] == 1) dif[msk]--;
            qq[tt[i]]++;
            T[msk][i] = vv[tt[i]];
        }
        forn (i, n)
            qq[tt[i]]--;
    }
    else
    {
        forn (i, n)
            T[msk][i] = 0;
    }
}

int main()
{
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif
    cin >> n;
    if (n == 1)
    {
        puts("0.0");
        return 0;
    }
    forn (i, n) s[i] = string(m, 'a');
    forn (j, 4)forn (i, n)s[i][j] = 'a' + rand() % 26;

    forn (i, n) {
        cin >> s[i];
        m = s[i].length();
    }

    forn (msk, (1 << m)) dif[msk] = -1;
    forn (msk, (1 << m)) g(msk);
    //forn (i, (1 << m)) cerr << dif[i] << " "; cerr << endl;
    forn (i, (1 << m))
        {
            int q = __builtin_popcount(i);
            int qd = n-dif[(1 << m) - 1 - i];
            d[i] = qd / ld(n);
            forn (j, m)
                if ((1 << j) & i)
                {
                    d[i] += d[i ^ (1 << j)] / q;
                }
        }
    //forn (i, (1 << m)) cerr << d[i] << " "; cerr << endl;
    printf("%.12lf\n", (double)d[(1 << m) - 1]);
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

#define LL long long
#define eps 1e-10
#define N 2000005
#define mod 1000000007
#define M 200020

LL d[N];
double dp[N];
char s[55][25];
int main(){
	int n, m;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%s", s[i]);
	m = strlen(s[0]);
	for(int i = 0; i < n; ++i)
		for(int j = i + 1; j < n; ++j){
			int tmp = 0;
			for(int k = 0; k < m; ++k){
				if(s[i][k] == s[j][k])
					tmp += 1 << k;
			}
			d[tmp] |= (1LL << i);
			d[tmp] |= (1LL << j);
		}
	int tot = 1 << m;
	for(int i = tot - 1; i >= 0; --i)
		for(int j = 0; j < m; ++j)
			if(i & (1 << j))
				d[i^(1<<j)] |= d[i];
	dp[0] = 1;
	double ans = 0;
	for(int s = 0; s < tot; ++s){
		int c = 0;
		for(int i = 0; i < m; ++i)
			if(s & (1 << i)) c++;
		for(int i = 0; i < m; ++i){
			if(!(s & (1 << i)))
				dp[s | (1<<i)] += dp[s] / (m - c);
		}
		for(int i = 0; i < n; ++i)
			if(d[s] & (1LL << i))
				ans += dp[s] / n;
	}
	printf("%.10f\n", ans);
	return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<bitset>
using namespace std;
typedef long long LL;
#define N 55
#define M 25

int n, len;
char str[N][M];
LL f[(1 << 20) + 10], bin[N];
double ans[(1 << 20) + 10];
double res;

int main() {
	int i, j, k, c;
	bin[0] = 1;
	for (i = 1; i < N; i++)
		bin[i] = (bin[i - 1] << 1);
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%s", str[i]);
	len = strlen(str[1]);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i != j) {
				int same = 0;
				for (k = 0; k < len; k++) {
					if (str[i][k] == str[j][k])
						same |= bin[k];
				}
				f[same] |= bin[j];
			}
		}
	}
	for (i = bin[len] - 1; i >= 0; i--) {
		for (j = 0; j < len; j++) {
			if (i & bin[j]) {
				f[i ^ bin[j]] |= f[i];
			}
		}
	}
	ans[0] = 1;
	for (i = 0; i < bin[len]; i++) {
		for (c = j = 0; j < len; j++) {
			if (i & bin[j])
				c++;
		}
		for (j = 0; j < len; j++) {
			if (!(i & bin[j]))
				ans[i | bin[j]] += ans[i] / (len - c);
		}
		for (j = 0; j < n; j++) {
			if (f[i] & bin[j])
				res += ans[i];
		}
	}
	printf("%.10f\n", res / n);
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <bitset>
using namespace std;
typedef double dou;
const int N=52;
const int M=1<<20;
const int MOD=1E7+9;
int n,m,s,g[M],sum;
dou p[M],ans;
bitset <N> d[M],o;
char st[N][N];

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%s",st[i]);
	m=strlen(st[1])-1; s=1<<(m+1);
	for (int i=0;i<s;i++)
		for (int j=m;j>=0;j--) if ((i&(1<<j))>0) g[i]++;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++) if (i!=j)
		{
			int same=0;
			for (int k=0;k<=m;k++) if (st[i][k]==st[j][k]) same+=1<<k;
			d[same][i]=1;
		}
	for (int i=s-1;i>=0;i--)
		for (int j=0;j<=m;j++) if (!(i&(1<<j))) d[i]|=d[i+(1<<j)];
	p[0]=1;
	for (int i=0;i<s-1;i++)
		for (int j=0;j<=m;j++) if ((i&(1<<j))==0)
		{
			o=d[i]^d[i+(1<<j)];
			sum=o.count();
			ans+=(dou)(g[i]+1)*sum*p[i]/n/(m+1-g[i]);
			p[i+(1<<j)]+=p[i]/(m+1-g[i]);
		}
	printf("%.10f",ans);
}

#include<cstdio>
#include<cstring>

using namespace std;

const int N=(1<<23)+5;

int n;
char a[55][55],s[55][55]; double f[N],ans;
int pool,nxt[1005][205],end[1005],key[N],m,ok[N],*stk[2005],top,pos[55];long long tmp[N];

#define For(i,x,y) for(int i=x;i<y;i++)

int chk(int k) {
/*
	double Ret=0;
	int len=0,pool=0;
	For (i,0,m) if (k>>i&1) len++;
	For (i,0,n) {
		int l=0,x=0;
		For (j,0,m) if (k>>j&1) {
			char ch=s[i][j];
			if (!nxt[x][ch])
				stk[++top]=&nxt[x][ch],nxt[x][ch]=++pool;
			x=nxt[x][ch];
		}
		pos[i]=x,end[x]++;
	}
	For (i,0,n) { if (end[pos[i]]==1) Ret++; end[pos[i]]=0; }
	while (top) (*stk[top])=0,top--;
	return Ret;
*/
	int Ret=0;
	For (j,0,n) if (tmp[k]>>j&1) Ret++;
	return Ret;
}

int main() {
	scanf("%d",&n);
	if (n==1) return printf("%.15lf\n",0.0),0;
	For (i,0,n) scanf("%s",s[i]);
	m=strlen(s[0]);

	For (i,0,n) For (j,0,n) if (i!=j) {
		int t=0;
		For (k,0,m) if (s[i][k]==s[j][k]) t|=1<<k;
		tmp[t]|=1ll<<j;
	}
	for (int i=(1<<m)-1;i;i--) For (j,0,m)
		if (i>>j&1) tmp[1<<j^i]|=tmp[i];
	For (i,1,1<<m)
		ok[i]=n-chk(i),key[i]=key[i-(i&-i)]+1;

	f[0]=1;
	For (i,0,1<<m) if (ok[i]!=n) {
		double pro=1./(m-key[i]);
		For (j,0,m) if (~i>>j&1)
			f[1<<j|i]+=f[i]*pro*(n-ok[1<<j|i])/(n-ok[i]);
		ans+=f[i];
	}
	printf("%.15lf\n",ans);
	return 0;
}
/*
10
aababbbaabaababababa
ababaababbabaaababbb
ababbababaaaaaabbbab
ababbbbabaabaaababaa
abbabbbaabbbbbbbaaba
baaabbabababbabbaaaa
bababbbbbbaaaabbaaba
babbaabaaabaaaabbaab
babbbaababaabbbbbaab
bbbbabaaababaabbabab

4.898647621728117

*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define MAX 100005

const int maxn=1100000;

int n;
char s[60][25];
double dp[maxn];
ll u[maxn];
ll bit[60]={1};
int cnt[maxn];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	if(n==1){printf("%.9f\n",0.0);return 0;}
	for(int i=1;i<=52;i++)bit[i]=bit[i-1]<<1;
	int len=strlen(s[0]);
	/*for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
				ll a=0;
				for(int k=0;k<len;k++)
					if(s[i][k]==s[j][k])a|=bit[k];
				u[a]|=(1LL<<i)|(1LL<<j);//�����⼸λ�Ժ����ļ������޷��ж�
		}
	}*/
	for(int i=0;i<n;++i)
        for(int j=i+1;j<n;++j){
            ll a=0;
            for(int k=0;k<len;k++)
                if(s[i][k]==s[j][k]) a|=bit[k];
            u[a]|=(1LL<<i)|(1LL<<j);
        }
	for(int i=bit[len]-1;i>=1;i--)
	{
		for(int j=0;j<len;j++)
		{
			if(i&bit[j]) u[i^bit[j]]|=u[i];
		}
	}
	for(int i=0;i<=bit[len]-1;i++)
		for(int j=0;j<n;j++)
			if(u[i]&(1LL<<j))cnt[i]++;//�жϹ���Щλ���Ժ�
	dp[bit[len]-1]=0;
	for(int i=bit[len]-2;i>=0;i--)
	{
		if(cnt[i]==0){dp[i]=0;continue;}
		int c=len;
		for(int j=0;j<len;j++)if(i&bit[j])c--;
		for(int j=0;j<len;j++)
		{
			if(i&bit[j])continue;
			dp[i]+=dp[i|bit[j]]*1.0/c*cnt[i|bit[j]]/cnt[i];
		}
		dp[i]++;
	}
	printf("%.9f\n",dp[0]);
	return 0;

}

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <iostream>
#include <string>
#include <math.h>
#include <string.h>
#include <stack>
#include <iomanip>
#include <map>
#include <queue>
using namespace std;
//printf("%.7f\n", double value);

typedef long long ll;
int n,m;
string s[60];
ll d[1<<21];
double totalguessed[21];
const ll one = 1;
bool has(ll mask, int pos) {
  return (mask >> pos) & 1;
}
int main () {
  cin >> n;
  for(int i=0; i<n; i++)
    cin >> s[i];
  m = s[0].size();

  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i==j) continue;
      int same =0;
      for(int k=0; k<m; k++) {
        if(s[i][k] == s[j][k]) same|= (one<<k);
      }
      d[same] |= (one << i);
    }
  }

  for(int mask = (1 << m) -1 ; mask >0; mask--) {
    for(int i=0; i<m;i ++) {
      if(has(mask,i))
        d[mask ^ (one<<i)] |= d[mask];
    }
  }

  double ans = 0;

  for(int mask=0; mask< (1<<m) ; mask++) {
    int qs = __builtin_popcount(mask) + 1;
    for(int i=0; i<m; i++) {
      if(!has(mask,i)) {
        ll tmp = d[mask] ^ d[mask^ (one<<i)];
        if(tmp==0) continue;
        int guess = __builtin_popcountll(tmp);
        totalguessed[qs] += guess;
      }
    }
  }

    for(int i=1; i<=m; i++) {
      double val = totalguessed[i]*i;
      for(int j=0;j<i-1;j++)
        val *= (double)(i-1-j) / (double)(m-j);
      ans += val/ (double)(m-i+1);
    }
    ans = ans/(double)n;
  cout << fixed << setprecision(15) << ans << endl;

  return 0;
}

// ba mei zi !

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define nrof(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}

template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }

template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }

template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }

template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }

#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif

//---------------------------head----------------------------

const int N = 55;
const int M = 22;

int n, m;
char str[N][M];
LL c[M][M];
LL dif[1050000];

void MEI()
{
	scf(n);
	rep(i, n) scanf("%s", str[i]);
	m = strlen(str[0]);

	rep(i, n) rep(j, i)
	{
		int msk = 0;
		rep(k, m) if(str[i][k] == str[j][k]) msk |= 1 << k;
		dif[msk] |= (1ll << i) | (1ll << j);
	}

	per(msk, (1 << m)) rep(i, m) if(msk >> i & 1) dif[msk ^ (1 << i)] |= dif[msk];

	c[0][0] = 1ll;
	forn(i, 1, m)
	{
		c[i][0] = c[i][i] = 1ll;
		forn(j, 1, i - 1) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
	return;
}

void ZI()
{
	flt ans = 0.0;

	rep(msk, (1 << m))
	{
#ifdef DEBUG
		printf("%d\t%d\n", msk, dif[msk]);
#endif
		ans += 1.0 * __builtin_popcountll(dif[msk]) / (1.0 * n * c[m][__builtin_popcount(msk)]);
	}

	printf("%.12f\n", ans);
	return;
}

/*
Main
code
is
over
.
If
you
are
in
a
hurry
trying
to
hack
me
you
don't
need
to
read
the
part
left
.
Trust
me
.
It
is
useless
.
My
code
always
gets
a
failed
system
test
,
so
it
will
be
pretty
easy
for
you
to
hack
me
.
Just
find
a
test
case
and
hack
.
Wish
you
all
happy
hack
.
 _____
/     \
| . . |
|     |
|  |  |
| --- |
| \_/ |
\_____/

*/

#ifdef DEBUG
struct I{ int x; I(){} I(int y):x(y){} bool operator <(const I &a) const{ return x < a.x; }};

pair<I,LL> time_limit_exceeded;
const bool FLAG = 1;
static vector<I> wrong_answer;
I *RP=new I;

I FUCK=min(I{*RP}, I{0});
static int memory_limit_exceeded[10];
vi O(){cout<<FUCK.x<<endl; vi ert; int x=0;
x=(int)hypot(3.0, 4.0); ert.pb(x);
if(x&1)exit(0);
auto t=lower_bound(ALL(ert), 5);
static list<int> runtime_error_;
return ert;}
#endif // DEBUG

#define MEI int
#define ZI main
MEI ZI()
{
#undef MEI
#undef ZI

    MEI();
    ZI();

#define BA return
#define MEI 0
#define ZI ;
BA MEI ZI
#undef BA
#undef MEI
#undef ZI
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

const int INF = 2147483647;

const int maxn = 2000010;
int vis[maxn];
double f[maxn];
int N, M;
char s[61][2000];
double ans;
long long same[110][110], check[maxn], cnt[maxn], num[maxn];

double dfs (int status)
{
  int tot = 0, flag = 0;
  if (vis[status]) return f[status];
  f[status] = 0; vis[status] = 1;
  if (!check[status]) return f[status] = 0;
  for (int k=1; k<=M; k++)
    if (!(status&(1<<k-1)))
      f[status] += dfs (status+(1<<k-1)), tot++;
  f[status] /= tot;
  f[status] += 1.0;
  return f[status];
}

int main ()
{
  //freopen ("CF483C.in", "r", stdin);
  //freopen ("CF483C.out", "w", stdout);
  cin >> N;
  if (N == 1) return puts ("0.00000000000"), 0;
  for (int i=1; i<=N; i++) scanf ("%s", s[i]+1);
  M = strlen(s[1]+1);
  for (int i=1; i<=N; i++)
    for (int j=1; j<=N; j++)
      if (j != i)
        for (int k=1; k<=M; k++)
          if (s[i][k] == s[j][k]) same[i][k] |= (1LL<<j-1);
  for (int i=1; i<(1<<M); i++) num[i] = num[i&i-1]+1;
  for (int i=1; i<=N; i++)
    {
      memset (check, 0, sizeof(check));
      check[0] = (1LL<<N)-1;
      for (int k=1; k<=M; k++)
        check[1<<k-1] = same[i][k];
      for (int k=1; k<(1<<M); k++)
        {
          check[k] = (check[k&-k]&check[k-(k&-k)]);
          if (check[k] != 0) cnt[k]++;
        }
    }
  for (int i=(1<<M)-1; i>=0; i--)
    {
      int tot = 0;
      for (int k=1; k<=M; k++)
        if (!(i&(1<<k-1)))
          {
            f[i] += f[i|(1<<k-1)];
            tot++;
          }
      if (tot) f[i] /= tot;
      f[i] += 1.0*cnt[i]/N;
    }
  printf ("%.10f\n", f[0]+1.0);
  return 0;
}

#include <bits/stdc++.h>
#define bptl(x) (__builtin_popcountll(x))
#define bit(x, y) (((x)>>(y))&1)
#define bpt(x) (__builtin_popcount(x))

using namespace std;
typedef double DO;
typedef long long INT;
#define NN 55
#define MM 22
char s[NN][MM];
DO f[MM];
INT g[1<<22];
int m;
void pre(){
	f[0]=1;
	for(int i=1;i<=m;i++) f[i]=f[i-1]*i/(m-i+1);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",s[i]);
	m=strlen(s[0]);
	pre();
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int x=0;
			for(int k=0;k<m;k++){
				if(s[i][k]==s[j][k]){
					x|=1<<k;
				}
			}
			g[x]|=1LL<<i;
			g[x]|=1LL<<j;
		}
	}
	for(int i=(1<<m)-1;i>=0;i--){
		for(int j=0;j<m;j++){
			if(!bit(i,j)){
				g[i]|=g[i|(1<<j)];
			}
		}
	}
	DO ans=0;
	for(int i=0;i<1<<m;i++){
		for(int j=0;j<m;j++){
			if(!bit(i,j)){
				INT x=g[i]^g[i|(1<<j)];
				ans+=bptl(x)*f[bpt(i)+1];
			}
		}
	}
	printf("%.12lf\n",ans/n);
    return 0;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T x) {print(x);putchar('\n');}

template<class T> void printsp(T x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U u, V v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U u, V v, W w){printsp(u);print(v, w);}

int power(int a, int b, int m, int ans=1) {

	for (; b; a=(INT)a*a%m,b>>=1) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 55

INT judge[1<<22];

char s[NN][NN];

int c[NN][NN];

DO p[NN];

void pre(int m){

	for(int i=0;i<=m;i++){

		for(int j=0;j<=i;j++){

			if(j==0||j==i) c[i][j]=1;

			else c[i][j]=c[i-1][j-1]+c[i-1][j];

		}

	}

	for(int i=0;i<=m;i++) p[i]=1.0/c[m][i];

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	gn(n);

	for(int i=0;i<n;i++) scanf("%s",s[i]);

	int nn=strlen(s[0]);

	pre(nn);

	if(n==1){

		puts("0.000000000");

		return 0;

	}

	for(int i=0;i<n;i++){

		for(int j=0;j<n;j++){

			int tot=0;

			if(i==j) continue;

			for(int k=0;k<nn;k++){

				if(s[i][k]==s[j][k]) tot+=(1<<k);

			}

			judge[tot]|=(1ll<<i);

			judge[tot]|=(1ll<<j);

		}

	}

	for(int i=(1<<nn);--i;){

		for(int j=0;j<nn;j++){

			if(i&(1<<j)){

				judge[i^(1<<j)]|=judge[i];

			}

		}

	}

	for(int i=0;i<n;i++) judge[0]|=(1ll<<i);

	DO ans=0;

	for(int i=1;i<(1<<nn);i++){

		int cnt=bpt(i);

		for(int j=0;j<nn;j++){

			if(i&(1<<j)){

				INT tmp=judge[i]^judge[i^(1<<j)];

				ans+=p[cnt-1]*bptl(tmp)/(nn-(cnt-1))*cnt;

			}

		}

	}

	cout<<fixed<<setprecision(20)<<ans/n<<endl;

	return 0;

}

#include <iostream>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <bitset>
#include <ctime>
#include <cmath>
#include <cstdio>

using namespace std;

const int maxN = 55;
const int maxLen = 20;

int cnt[1 << maxLen];
double mfact[maxN];
long long msk[1 << maxLen];
long long f[maxN];

int n;
string s[maxN];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    for (int i = 0; i < (1 << maxLen); ++i) {
        cnt[i] = bitset<23>(i).count();
    }

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    int m = s[0].length();
    mfact[0] = 1;
    for (int i = 1; ; ++i) {
        if (m - i + 1 == 0) {
            break;
        }
        mfact[i] = 1. / (m - i + 1.) * mfact[i - 1];
    }
    for (int i = 0; i <= 20; ++i) {
        mfact[i] *= i;
    }

    double res = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            long long cmask = 0;
            for (int k = 0; k < m; ++k) {
                if (s[i][k] == s[j][k]) {
                    cmask += (1LL << k);
                }
            }
            msk[cmask] |= (1LL << i);
            msk[cmask] |= (1LL << j);
        }
    }

    for (int i = (1 << m) - 1; i >= 0; --i) {
        for (int j = 0; j < m; ++j) {
            if (i & (1 << j)) {
                msk[i - (1 << j)] |= msk[i];
            }
        }
    }

    f[0] = 1;
    for (int i = 1; i < maxN; ++i) {
        f[i] = f[i - 1] * i;
    }
    for (int i = (1 << m) - 1; i >= 0; --i) {
        if (!msk[i]) {
            continue;
        }

        for (int j = 0; j < m; ++j) {
            if (!(i & (1 << j))) {
                bitset<55> b = msk[i] - msk[i + (1 << j)];
                res += mfact[cnt[i + (1 << j)]] * b.count() * f[cnt[i]];
            }
        }
    }

    printf("%.10lf\n", res / n);

    return 0;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 55

char s[NN][NN];

INT mask[1<<20];

DO C[NN][NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	gn(n);

	if(n==1) return puts("0.0"), 0;

	for(int i=0; i<n; i++) scanf("%s", s[i]);

	int m=strlen(s[0]);

	for(int i=0; i<n; i++) for(int j=i+1; j<n; j++){

		int val=0;

		for(int k=0; k<m; k++){

			if(s[i][k]==s[j][k]) val|=(1<<k);

		}

		mask[val]|=(1LL<<i);

		mask[val]|=(1LL<<j);

	}

	int all=1<<m;

	for(int i=all; --i; ){

		for(int j=0; j<m; j++) if(bit(i, j)) mask[i^(1<<j)]|=mask[i];

	}

	DO ans=0;

	for(int i=0; i<=m; i++) for(int j=0; j<=i; j++){

		if(i==0 || i==j) C[i][j]=1;

		else C[i][j]=C[i-1][j-1]+C[i-1][j];

	}

	for(int i=0; i<=m; i++) for(int j=0; j<=i; j++) C[i][j]=1/C[i][j];

	mask[0]=(1LL<<n)-1;

	for(int i=0; i<all; i++){

		for(int j=0; j<m; j++){

			if(!bit(i, j)){

				int ii=i|(1<<j);

				int known=bptl(mask[ii]^mask[i]);

				ans+=C[m][bpt(i)]/(m-bpt(i))*known*bpt(ii);

			}

		}

	}

	printf("%.15lf\n", ans/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;

#pragma comment(linker, "/STACK:16777216")

#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define PB pop_back()
#define iOS ios_base::sync_with_stdio(false)
#define sqr(a) (((a) * (a)))
#define all(a) a.begin() , a.end()
#define error(x) cerr << #x << " = " << (x) <<endl
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define L(x) (((x)<<1)+1)
#define R(x) (((x)<<1)+2)
#define umap unordered_map
//#define double long double
#define mod 1000000007
#define mod1 1000000009
#define LIMIT 10000000000000000LL
#define MAX1 1000000000
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d%d",&n,&m)
#define pi(n) printf("%d\n",n)
const int inf=0x3f3f3f3f;
#define MAX 1000005
#define N 410
#define INF 100000000
const string debug_line="yolo";
#define debug error(debug_line)
const double PI=4*atan(1);
#define read() freopen("mergedoutput.txt","r",stdin)
#define write() freopen("output.txt","w",stdout)
//template <typename T> using os =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef complex<double> point;

char s[50][50];
ll dp[(1<<21)];
ll nCr[101][101];

int main(){
    int n;
    scanf("%d",&n);

    For(i,0,101){
        nCr[i][0]=1.0;
    }

    For(i,1,21){
        For(j,1,i+1){
            nCr[i][j]=nCr[i-1][j-1]+nCr[i-1][j];
        }
    }

    For(i,0,n){
        scanf("%s",s[i]);
    }
    int m=strlen(s[0]);
    For(i,0,n){
        For(j,0,n){
            if(i!=j){
                ll temp1=0;
                For(k,0,m){
                    if(s[i][k]==s[j][k]){
                        temp1=(temp1 | (1LL<<k));
                    }
                }
                dp[temp1]=(dp[temp1] | (1LL<<i));
            }
        }
    }

    rof(mask,(1<<m)-1,-1){
        For(j,0,m){
            if(!((1<<j) & mask)){
                dp[mask] |=dp[mask ^ (1LL<<j)];
            }
        }
    }

    double answer1=0;
    rof(mask,(1<<m)-1,-1){
        //error(dp[mask]);
        //printf("%d--%d--%d---%lld\n",mask,m,__builtin_popcount(mask),nCr[n][__builtin_popcount(mask)]);
        answer1=(answer1+(1.0*__builtin_popcountll(dp[mask]))/((1.0*n)*nCr[m][__builtin_popcount(mask)]));
    }
    printf("%.9lf\n",answer1);
return 0;}

#include <bits/stdc++.h>

using namespace std;

const int N = 20, M = 150;

int n;
char s[M][N + 10];

typedef long long li;
typedef long double ld;

li d[1 << N];

inline bool has(li msk, int pos) {
  return msk >> pos & 1;
}

ld prob[N + 10];
ld totalGuessed[N + 10];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  int m = strlen(s[0]);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) if (i != j) {
      int same = 0;
      for (int k = 0; k < m; ++k) {
        if (s[i][k] == s[j][k]) same |= (1 << k);
      }
      d[same] |= (1ll << i);
    }
  }
  for (int msk = (1 << m) - 1; msk; --msk) {
    for (int i = 0; i < m; ++i) {
      if (has(msk, i)) d[msk ^ (1 << i)] |= d[msk];
    }
  }
  ld ans = 0;
  for (int msk = 0; msk < 1 << m; ++msk) {
    int moves = __builtin_popcount(msk) + 1;
    for (int i = 0; i < m; ++i) if (!has(msk, i)) {
      li res = d[msk] ^ d[msk ^ (1 << i)];
      if (res == 0) continue;
      int cnt = __builtin_popcountll(res);
      totalGuessed[moves] += cnt;
    }
  }
  for (int i = 1; i <= m; ++i) {
    ld val = totalGuessed[i] * i;
    for (int j = 0; j < i - 1; ++j) val *= ld(i - 1 - j) / ld(m - j);
    ans += val / ld(m - i + 1);
  }
  ans /= ld(n);
  printf("%.12f\n", (double)ans);
  return 0;
}

/*
AuThOr GaRyMr
*/
#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 KEEP while(1)
#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 double (long double)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
const int MAXM=20;
LL bad[1<<MAXM];
double dp[1<<MAXM][2];//dp[mask]表示询问了mask里的位置，并且询问到了的概率
LL change(LL S,int pos){
	return S|(1ll<<(pos-1));
}
LL query(LL S,int pos){
	return S&(1ll<<(pos-1));
}int n,m,BIT;
int cnt[1<<MAXM],cnt_bit[1<<MAXM];
void update(int to,int from){
	dp[to][1]+=dp[from][1]/double(m-cnt_bit[from])*double(cnt[to])/double(cnt[from]);
	dp[to][0]+=dp[from][1]/double(m-cnt_bit[from])*double(cnt[from]-cnt[to])/double(cnt[from]);
}
int main(){
//	fastio;
	cin>>n;
	if(n==1){
		cout<<"0.0000000000000000"<<endl;
		return 0;
	}
	string s[55];
	rb(i,1,n){
		cin>>s[i];
		s[i]='$'+s[i];
	}
	m=s[n].length()-1;
	BIT=1<<m;
	BIT--;
	rb(i,0,BIT){
		int tmp=i;
		while(tmp){
			cnt_bit[i]+=bool(tmp&1);
			tmp>>=1;
		}
	}
	rb(i,1,n){
		rb(j,1,n)
		{
			LL DIff=0ll;
			if(j==i) continue;
			rb(k,1,m){
				if(s[i][k]==s[j][k]){
					DIff=change(DIff,k);
				}
			}
			bad[DIff]=change(bad[DIff],i);
			bad[DIff]=change(bad[DIff],j);
		}
	}
	rl(i,BIT,1){
		rb(j,1,m){
			if(query(i,j)){
				bad[i-(1<<(j-1))]|=bad[i];
			}
		}
	}
	bad[0]=(1ll<<n)-1;
	rb(i,0,BIT){
		rb(j,1,n){
			if(query(bad[i],j)){
				cnt[i]++;
			}
		}
	}
//	rb(i,0,BIT)
//	{
//		cout<<i<<" "<<cnt[i]<<endl;
//	}
	dp[0][0]=0.0;
	dp[0][1]=1.0;
//	cout<<BIT<<endl;
	rb(mask,1,BIT){
		rep(j,m){
			if(mask&(1<<j)){
				int newmask=mask^(1<<j);
				if(dp[newmask][1]>0.0)
				update(mask,newmask);
			}
		}
	}
	double res=0;
	rb(i,1,BIT){
		res+=(double)cnt_bit[i]*dp[i][0];
	}
	printf("%.17f\n",res);
	return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <bitset>
using namespace std;

#define ri(X) scanf("%d", &(X))
#define pi(X) printf("%d", (X))
#define mp(X,Y) make_pair(X,Y)
#define pb(X) push_back(X)
#define lint long long
#define pii pair<int,int>
#define inf 1e9
#define linf 1e18
#define X first
#define Y second
#define all(X) (X).begin(),(X).end()

int n, m;
const int mm = 21;
const int mn = 51;

lint d[1<<mm];

string s[mn];

set<lint> p2;

lint back[1<<mm];
lint tot;
double dp[1<<mm];

int moves[mm];

void p(int i){
  bitset<3> x(i);
  cout << x;
}

int main(){
  for(int i = 0; i < mn; i++){
    p2.insert(1ll<<i);
  }
  ri(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }m = s[0].size();

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j) continue;
      int st = 0;
      for(int k = 0; k < m; k++){
        if(s[i][k] == s[j][k]) st |= (1<<k);
      }
      //cout << i << " " << j << " "; p(st); cout << endl;
      d[st] |= (1ll<<i);
    }
  }

  for(int st = (1<<m)-1; st >= 0; st--){
    for(int i = 0; i < m; i++){
      if((st & (1<<i)) == 0) continue;
      d[st ^ (1<<i)] |= d[st];
    }
  }

  for(int st = 0; st < (1<<m); st++){
    int pc = __builtin_popcount(st);
    for(int i = 0; i < m; i++){
      if((st & (1ll<<i)) == 0) continue;
      lint res = (d[st] ^ d[st ^ (1 << i)]);
      if(res == 0) continue;
      moves[pc] += __builtin_popcountll(res);
    }
  }
  double res = 0, rp;
  for(int i = 1; i <=  m; i++){
    rp = moves[i]*i;
    for(int j = 0; j < i-1; j++){
      rp = rp* (i-j-1) / (m-j);
    }
    res += rp/(m-i+1);
    //cout << moves[i] << " ";
  }//cout << endl;

  printf("%.15lf\n",res/n);

  return 0;
}

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

typedef unsigned int ull;

const int MAXN = 55;
const int MAXL = 20;
const ull P = 7111;
int N, L, ok[1 << MAXL];
double dp[1 << MAXL];
ull val[1 << MAXL][MAXN], hval[MAXL][MAXN];
string S[MAXN];

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S[i];
    L = S[i].size();
    ull p = 1;
    for(int j = 0; j < L; j++){
      hval[j][i] = p * S[i][j];
      p *= P;
    }
  }
  for(int i = 1; i < (1 << L); i++){
    int k = __builtin_ffs(i) - 1, pk = (1 << k);
    for(int j = 0; j < N; j++){
      val[i][j] = val[i ^ pk][j] + hval[k][j];
    }
  }
  for(int i = 0; i < (1 << L); i++){
    sort(val[i], val[i] + N);
    bool a = 1, b;
    for(int j = 1; j < N; j++){
      b = (val[i][j - 1] != val[i][j]);
      ok[i] += (a & b);
      a = b;
    }
    ok[i] += a;
  }
  for(int i = (1 << L) - 1; i >= 0; i--){
    dp[i] = N - ok[i];
    int k = L - __builtin_popcount(i);
    for(int j = 0; j < L; j++){
      if(i & (1 << j)) continue;
      dp[i] += dp[i ^ (1 << j)] / k;
    }
  }
  cout << fixed << setprecision(9);
  cout << dp[0] / N << '\n';
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <bitset>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;
const int mod = (int) 1e9 + 7;
using namespace std;
int n;
string s[55];
ll d[1<<20];
int m;
double dp[1<<20];
int u[1<<20];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	m = s[0].size();
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i == j) continue;
			int mask = 0;
			for(int t = 0; t < m; t++) if(s[i][t] == s[j][t]) mask |= 1<<t;
			d[mask] |= (1ll<<i) | (1ll<<j);
		}
	}
	for(int i = (1<<m)-2; i >= 0; i--) {
		for(int j = 0 ;j < m; j++)
			d[i] |= d[i|(1<<j)];
	}
	for(int i = (1<<m)-2; i >= 0;i--) {
		int cnt = m - __builtin_popcount(i);
		ll x = __builtin_popcountll(d[i]);
		for(int j = 0; j < m; j++) {
			if((1<<j) & i) {

			}else{
				if(d[i]){
					dp[i] += (dp[i|(1<<j)] + x)/cnt;
				}
			}
		}
	}
	printf("%.12lf", dp[0]/n);
}
int main () {
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define lowbit(x) ((x)&(-x))
using namespace std;
int len,n;
string s[50+3];
LL pow[50+3];
LL f[1<<21],p[1<<21];
double g[1<<20];
int main(){
	pow[0]=1;
	for (int i=1;i<=50;i++) pow[i]=pow[i-1]*2;
	p[0]=0;
	for (int i=1;i<(1<<21);i++){
		for (int x=i;x;p[i]++,x-=lowbit(x));
	}
	scanf("%d",&n);
	for (int i=1;i<=n;i++) cin >> s[i];
	len=s[1].size();
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if (i==j) continue;
			int t=0;
			for (int k=0;k<len;k++){
				if (s[i][k]==s[j][k]) t|=pow[k];
			}
			f[t]|=pow[j-1];
		}
	}
	for (int i=pow[len]-1;i>=0;i--){
		for (int j=0;j<len;j++){
			if ((i&pow[j])!=0){
				f[i^pow[j]]|=f[i];
			}
		}
	}
	g[0]=1;
	double ans=0;
	for (int i=0;i<pow[len];i++){
		int num=len-p[i];
		for (int j=0;j<len;j++){
			if ((i&pow[j])==0) g[i|pow[j]]+=g[i]/num;
		}
		for (int j=1;j<=n;j++){
			if ((f[i]&pow[j-1])!=0) ans+=g[i];
		}
	}
	printf("%.10lf\n",ans/n);
	return 0;
}

#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 55
#define M 1200010
using namespace std;
ll n,m,iden[M];
double dp[M];//possibility of finding out if you ask a query of mask
double ans=0;
string s[N];
int main(){
	ll i,j,k,mask,cnt;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	if(n==1)
	{
		cout<<0<<endl;
		return 0;
	}
	m=s[0].size();
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			mask=0;
			for(k=0;k<m;k++)
			{
				if(s[i][k]==s[j][k]&&i!=j)
				{
					mask|=((ll)1<<k);
				}
			}
			iden[mask]|=((ll)1<<i)|((ll)1<<j);
		}
	}
	for(i=(1<<m)-1;i>=0;i--)
	{
		dp[i]=0;
		for(j=0;j<m;j++)
		{
			iden[i]|=iden[i|((ll)1<<j)];
		}
	}
	dp[0]=1;
	for(i=0;i<(1<<m);i++)
	{
		for(j=0;j<m;j++)
		{
			if(!(i&(1<<j)))
			{
				dp[i|(1<<j)]+=dp[i]/(double)(m-__builtin_popcount(i));
			}
		}
		cnt=0;
		for(j=0;j<n;j++)
		{
			if(iden[i]&((ll)1<<j))
			{
				cnt++;
			}
		}
		ans+=dp[i]*(double)cnt/(double)n;
	}
	printf("%.12f\n",ans);
	return 0;
}

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

int N,L;
string a[60];
ll ids[(1<<20)];
ld p[1<<20];

int bits(ll x){
	return __builtin_popcountll(x);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;

	int i,j,k,mask;
	for (i=0; i<N; i++)
		cin >> a[i];

	L=a[0].length();
	for (i=0; i<N; i++)
		for (j=i+1; j<N; j++){
			int mask=0;
			for (k=0; k<L; k++)
				if (a[i][k]==a[j][k])
					mask|=(1<<k);

			ids[mask]|=(1ll<<i);
			ids[mask]|=(1ll<<j);
		}

	p[0]=1;
	for (mask=1; mask<(1<<L); mask++){
		for (i=0; i<L; i++)
			if (mask&(1<<i))
				p[mask]+=p[mask-(1<<i)];

		p[mask]*=ld(1)/(L-bits(mask)+1);
	}

	ld res=0;
	for (mask=(1<<L)-1; mask>=0; mask--){
		res+=ld(1)/N*bits(ids[mask])*p[mask];
		for (i=0; i<L; i++)
			if (mask&(1<<i))
				ids[mask-(1<<i)]|=ids[mask];
	}

	cout << fixed << setprecision(12) << res << "\n";
	return 0;
}

//In the name of Allah

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
#include <limits>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
using namespace std;

int n, m;
char s[55][25];

long long x[1 << 20];
double dp[1 << 20];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%s", s[i]);
    m = strlen(s[0]);

    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)if(i != j){
        int mask = 0;
        for(int k = 0; k < m; k++)
            if(s[i][k] == s[j][k])mask |= (1 << k);
        x[mask] |= (1LL << i);
    }
    for(int mask = (1 << m) - 1; mask > 0; mask--)
    for(int k = 0; k < m; k++)if(mask & (1 << k))
        x[mask ^ (1 << k)] |= x[mask];

    dp[0] = 1.0;
    double total = 0.0;

    for(int mask = 0; mask < (1 << m); mask++){
        int cnt = 0;
        for(int k = 0; k < m; k++)if(!(mask & (1 << k)))cnt++;

        for(int k = 0; k < m; k++)if(!(mask & (1 << k))){
            dp[mask ^ (1 << k)] += dp[mask] / cnt;

            long long cmask = x[mask] ^ x[mask ^ (1 << k)]; int c = 0;
            while(cmask > 0)cmask -= cmask & (-cmask), c++;

            total += (dp[mask] / cnt) * (m - cnt + 1) * (1.0 * c / n);
        }
    }
    printf("%.015f\n", total);

    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define tanao AK_IOI
#define dgklr AK_IOI
using namespace std;
const int maxn=55;
const int maxm=25;
int n,m,pre[1<<20],full;
char a[maxn][maxm];
double dp[1<<20],ans;
ll cnt[1<<20];
inline int read(){
	int res=0,f_f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f_f;
}
int main(){
	n=read();
	for (int i=1;~(n-i);i++) scanf("%s",a[i]+1),m=strlen(a[i]+1);
	if(n==0){printf("0\n");return 0;}
	full=(1<<m)-1;
	for (int mask=0;~(full-mask);mask++)
		for (int i=1;~(m-i);i++) if(mask&(1<<i-1)) pre[mask]++;
	for (int i=1;~(n-i);i++){
		for (int j=1;~(n-j);j++) if(i^j){
			int state=0;
			for (int k=1;~(m-k);k++)
				if(a[i][k]==a[j][k]) state|=(1LL<<k-1);
			cnt[state]|=(1LL<<i-1)|(1LL<<j-1);
		}
	}
	for (int mask=full;~mask;mask--)
		for (int i=1;~(m-i);i++)
			if(mask&(1LL<<i-1)) cnt[mask^(1LL<<i-1)]|=cnt[mask];
	dp[0]=1.0;
	for (int mask=0;~(full-mask);mask++){
		int sum=0;
		for (int i=1;~(n-i);i++) if(cnt[mask]&(1LL<<i-1)) sum++;
		ans+=dp[mask]*sum/n;
		for (int i=1;~(m-i);i++){
			if(mask&(1<<i-1)) continue;
			dp[mask|(1<<i-1)]+=dp[mask]/(m-pre[mask]);
		}
	}
	printf("%.10lf\n",ans);
	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string>
#include <vector>
#define mp make_pair
#define pii pair<int,int>
#define For(i,a,n)  for(int i=(a);i<=(n);i++)
#define Forn(i,a,n) for(int i=(a);i>=(n);i--)
#define REP(i,n)    for(int i=(1);i<=(n);i++)
using namespace std;
const int maxn=(1<<20)+5;
const long long UPL=(1LL<<20)-1;

inline void setIO(string a){
#ifndef ONLINE_JUDGE
	string in=a+".in",out=a+".out";
	freopen(in.c_str(),"r",stdin);
	freopen(out.c_str(),"w",stdout);
#endif
}

int n,m,upl;
char s[55][25];
long long F[maxn],cnt[25];
int clz[maxn];

int count(long long s){
	return clz[(s>>40)&UPL]+clz[(s>>20)&UPL]+clz[s&UPL];
}

int main(){
	scanf("%d\n",&n);
	For(i,1,n) gets(s[i]+1);m=strlen(s[1]+1);
	For(i,1,n)
	For(j,1,n){
		if(i==j)continue;
		int msk=0;
		For(k,1,m)
		if(s[i][k]==s[j][k]){
			msk|=1<<(k-1);
		}
		F[msk]|=1LL<<(i-1);
	}upl=(1<<m)-1;
	For(i,0,m-1)
	For(j,0,upl){
		if((j>>i)&1) F[j^(1<<i)]|=F[j];
	}
	For(i,0,UPL) clz[i]=clz[i>>1]+(i&1);
	For(i,0,upl){
		int A=clz[i]+1;
		For(j,0,m-1){
			if((i>>j)&1)continue;
			long long sum=F[i]^F[i^(1<<j)];
			cnt[A]+=count(sum);
		}
	}
	long double ans=0;
	For(i,1,m){
		long double gx=1.*cnt[i]*i;
		For(j,0,i-2) gx*=1.*(i-1-j)/(m-j);
		gx/=(m-i+1);
		ans+=gx;
	}
	printf("%.14lf\n",double(ans/n));
	return 0;
}

#include<cstdio>
#include<cstring>

#define For(i, _l, _r) for (int i = (_l), i##r = (_r) ; i <= (i##r) ; ++i)
#define Lop(i, _l, _r) for (int i = (_l), i##r = (_r) ; i >= (i##r) ; --i)
#define Rep(i, _l, _r) for (int i = (_l) ; i ; i = (_r))

template <typename tp> inline tp max (tp x, tp y) { return x > y? x: y ; }
template <typename tp> inline tp min (tp x, tp y) { return x < y? x: y ; }
template <typename tp>
inline bool chkmax (tp& x, tp y) { return (x >= y)? false: (x = y, true) ; }
template <typename tp>
inline bool chkmin (tp& x, tp y) { return (x <= y)? false: (x = y, true) ; }

static const int len = 1 << 20 | 1 ;
char buffer[len], *Ser, *Ter ;
inline char Getchar() {
	if (Ser == Ter) Ter = (Ser = buffer) + fread (buffer, 1, len, stdin) ;
	return (Ser == Ter)? (char)EOF: (*Ser++) ;
}

template <typename tp>
inline tp scanf (tp& in) {
	in = 0 ; char ch = getchar() ; tp f = 1 ;
	for (; ch > '9' || ch < '0' ; ch = getchar()) if (ch == '-') f = -1 ;
	for (; ch >='0' && ch <='9' ; ch = getchar()) in = in * 10 + ch - '0' ;
	return in *= f ;
}

typedef long long LL ;
static const int max1 = 51 ;
static const int max2 = 21 ;
static const int max3 = (1 << 20) + 11 ;

int n ;
int m ;

char si[max1][max2] ;

LL f[max3] ;

double g[max3] ;

template <typename tp>
inline int get (tp x) {
	int res = 0 ;
	for (; x ; x &= x - 1) ++res ;
	return res ;
}

int main() {

	scanf(n) ;
	For (i, 1, n) scanf ("%s", si[i] + 1) ;
	m = strlen (si[1] + 1) ;

	For (i, 1, n) For (j, i + 1, n) {
		int status = 0 ;
		For (k, 1, m) if (si[i][k] == si[j][k])
			status |= 1 << k - 1 ;
		f[status] |= (1LL << i - 1) | (1LL << j - 1) ;
	}

	int full = (1 << m) - 1 ;
	Lop (i, full, 1) For (k, 1, m)
		if (i >> k - 1 & 1) f[i ^ (1 << k - 1)] |= f[i] ;

	double output = 0.0 ;

	g[0] = 1.0 ;
	For (i, 0, full) {
		int t = get (i) ;
		For (k, 1, m) if (!(i >> k - 1 & 1))
			g[i | (1 << k - 1)] += g[i] / (m - t) ;
		output += g[i] * get (f[i]) ;
	}

	printf ("%.10lf\n", output / n) ;

	return 0 ;
}

#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <iomanip>
using namespace std;

string s[55];
long long bad[1 << 20];
double  dp[1 << 20];
int n, m;

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(16);
    cin >> n;
    for (int i = 0; i < n; ++ i) {
        cin >> s[i];
    }
    m = (int)s[0].length();
    for (int i = 0; i < n; ++ i) {
        for (int j = i + 1; j < n; ++ j) {
            int diff = 0;
            for (int k = 0; k < m; ++ k) {
                if (s[i][k] == s[j][k]) {
                    diff |= 1 << k;
                }
            }
            bad[diff] |= (1ll << i) + (1ll << j);
        }
    }
    for (int i = (1 << m) - 2; i >= 0; -- i) {
        for (int j = 0; j < m; ++ j) {
            if (((i >> j) & 1) == 0) {
                dp[i] += dp[(i | (1 << j))];
                bad[i] |= bad[(i | (1 << j))];
            }
        }
        dp[i] = dp[i] / (m - __builtin_popcount(i)) + __builtin_popcountll(bad[i]) * 1. / n;
        //cout << i << " " << dp[i] << " " << bad[i] << endl;
    }
    cout<<dp[0]<<endl;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	string s[52];
	cin >> n;
	rep(i,n)cin >> s[i];
	int m = s[0].size();

	static ld cnt[1<<20];
	cnt[0] = 0.0;
	for(int i = 1 ; i < (1<<20) ; i ++){
		cnt[i] = cnt[i/2] + (ld)(i&1);
	}

	//puts("DEBUG");

	static ll dp0[1<<20];
	rep(i,n){
		rep(j,n){
			if(i == j)continue;
			int a = 0;
			rep(k,m){
				if(s[i][k] == s[j][k])a += 1<<k;
			}
			dp0[a] |= ((ll)1)<<i;
		}
	}
	rrep(i,(1<<20)){
		rep(j,20){
			if((i>>j)&1)dp0[i^(1<<j)] |= dp0[i];
		}
	}

	//puts("DEBUG");

	static ld e[1<<20];
	rep(i,(1<<20)){
		e[i] = n;
		while(dp0[i] > 0){
			e[i] -= dp0[i]%2;
			dp0[i] >>= 1;
		}
		e[i] /= (ld)n;
	}

	/*puts("DEBUG");
	rep(i,8){
		printf("%d %lf\n",i,e[i]);
	}*/

	ld ret = 0.0;
	static ld dp1[1<<20];
	static ld dp2[1<<20];
	dp1[0] = 1.0;
	rep(i,(1<<m)){
		ld sum = dp1[i]+dp2[i];
		ret += (sum*e[i]-dp2[i])*cnt[i];
		dp2[i] = sum*e[i];
		dp1[i] = sum*(1.0-e[i]);
		rep(j,m){
			if(((i>>j)&1) == 0){
				dp1[i|(1<<j)] += dp1[i]/((ld)m-cnt[i]);
				dp2[i|(1<<j)] += dp2[i]/((ld)m-cnt[i]);
			}
		}
	}
	cout.precision(20);
	cout << ret << endl;
}

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
long long n,m,pos;
pair<long long,long long> a[55];
double dp[1111111],cnt,ans;
long long f[1111111];
string s[55];
int main()
{
	cin>>n;
	for (long long i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	m=s[1].size();
	for (long long i=1;i<=n;i++)
	{
		for (long long j=i+1;j<=n;j++)
		{
			pos=0;
			for (long long k=0;k<m;k++)
			{
				if (s[i][k]==s[j][k]) pos|=(1<<k);
			}
			f[pos]|=(1ll<<(j-1ll));
			f[pos]|=(1ll<<(i-1ll));
		}
	}
	for (long long i=(1<<m)-1;i>0;i--)
	{
		for (long long j=0;j<m;j++)
		{
			if (i&(1<<j)) f[i^(1<<j)]|=f[i];
		}
	}
	dp[0]=1.00;
	for (long long i=1;i<(1<<m);i++)
	{
		cnt=1.00;
		for (long long j=0;j<m;j++)
		{
			if (!(i&(1<<j))) cnt+=1.00;
		}
		for (long long j=0;j<m;j++)
		{
			if (i&(1<<j))
			{
				dp[i]+=dp[i^(1<<j)]/cnt;
			}
		}
		for (long long j=0;j<n;j++)
		{
			if (f[i]&(1ll<<j)) ans+=dp[i];
		}
	}
	if (n==1) printf("0.00000000\n");
	else printf("%.9lf\n",ans/(double)n+1.00);
	return 0;
}

//I read the news today, oh boy
//About a lucky man who made the grade

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N=1<<20;
ll here[N+100];
int n,m;
ld ter[N+100];

int go(string &s1,string &s2){
	int val=0;
	For(i,0,m)if(s1[i]==s2[i])val|=(1<<i);
	return val;
}

int main(){
	fastio;
	cout<<fixed<<setprecision(14);
	cin>>n;
	vector<string>vec(n);
	For(i,0,n)cin>>vec[i];
	m=sz(vec[0]);
	For(i,0,n)For(j,i+1,n)if(i!=j){
		int mask=go(vec[i],vec[j]);
		here[mask]|=(1LL<<i)|(1LL<<j);
	}
	int lim=(1<<m)-1;
	roF(mask,lim,0)For(i,0,m)
		here[mask]|=here[mask|(1<<i)];

	ter[lim]=0;
	roF(i,lim-1,0){
		ter[i]=__builtin_popcountll(here[i]);
		ld val=0;
		For(j,0,m)if(1-((i>>j)&1))
			val+=ter[i|(1<<j)];
		ter[i]+=val/(m-__builtin_popcount(i));
	}
	cout<<ter[0]/n<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

int n,m;

ll ms[2000001];
ll dp[2000001];

ll pro(int msk){
    if(dp[msk] != -1)return dp[msk];
    ll r= ms[msk];
    for(int i=0 ;i <m ;i ++){
        if(!(msk&(1<<i))){
            r |= pro(msk|(1<<i));
        }
    }
    return dp[msk] = r;
}

int c[2000001];

double dp1[2000001];

double f(int msk){
    if(dp1[msk] > -1e-3)return dp1[msk];

    double r = 1.0*c[msk]/n;
    int ze = 0;
    for(int i=0 ;i <m ; i++)
        if(!(msk&(1<<i)))ze++;
    r *= m-ze;
    for(int i=0 ; i<m ;i ++){
        if(!(msk&(1<<i))){
            r += f(msk|(1<<i))*1.0/ze;
        }
    }
    if(ze){
        r -= 1.0*c[msk]/(n)*(m-ze+1);
    }
    return dp1[msk] = r;
}
string s[100];

int main() {
    ios::sync_with_stdio(0);
    memset(dp,-1,sizeof dp);
    memset(dp1,-1,sizeof dp1);

    cin>>n;
    for(int i=0 ; i<n ;i ++){
        cin>>s[i];
    }
    m = s[0].length();
    int en = 1<<m;

    for(int i=0 ;i <n ; i++){
        for(int j=0 ; j<n ; j++){
            if(i == j)continue;
            int r1 = 0;
            for(int k=0 ;k <m ; k++){
                if(s[i][k] == s[j][k])r1 |= (1<<k);
            }
            ms[r1] |= (1LL<<i);
        }
    }
    pro(0);

    for(int i=0 ;i <en ;i ++){
        int r =0;
        for(int j=0 ; j<n ; j++){
            if((1LL<<j)&dp[i])
                r++;
        }

        c[i] = n-r;
    }

    cout<<fixed<<setprecision(10)<<f(0)<<endl;

    return 0;
}

#include <bits/stdc++.h>

#define PB push_back
#define SZ(c) ll((c).size())
#define ALL(c) (c).begin(), (c).end()
#define CONTAINS(c, x) ((c).find(x)!=(c).end())
#define REP(i, c) for(int i=0; i<c; i++)
#define foreach(it, c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define WAIT cout<<flush, system("PAUSE")
using namespace std;
typedef long long ll;
typedef double ld;
const ld EPS = 1e-10;
#define MAX 55

int N, M;
string s[MAX];
ld f[MAX], p[MAX], cost[MAX], curr, sol;
int eq[MAX][MAX], len[1<<22];
ll pending[1<<22];

int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout<<setprecision(15)<<fixed;

    cin >> N;
    REP(I, N) cin>>s[I];
    if (N==1){
        cout << 0 << endl;
        return 0;
    }

    M = SZ(s[0]);
    p[0]=f[0]=cost[0]=1;
    REP(I, MAX-1) f[I+1]=f[I]*(I+1);
    REP(I, MAX-1) p[I+1]=p[I]*(1.0/(M-I));
    REP(I, MAX)   cost[I+1]=f[I+1]*p[I+1];
    REP(msk, 1<<M) len[msk]=__builtin_popcount(msk);

    REP(I, N){
        pending[0] |= (1ll<<I);
        REP(K, N) if (I!=K){
            eq[I][K]=0;
            REP(L, M) if (s[I][L]==s[K][L]) eq[I][K]|=(1<<L);
            pending[eq[I][K]] |= (1ll<<I);
        }
    }

    for(int msk=(1<<M)-1; msk>0; msk--) if (pending[msk]){
        int tmp = msk;
        while(tmp>0){
            int lo = tmp&(-tmp);
            pending[msk^lo] |= pending[msk];
            tmp -= lo;
        }
    }

    REP(msk, 1<<M)  sol += __builtin_popcountll(pending[msk])*cost[len[msk]];
    cout << sol/N << endl;
}

#include<bits/stdc++.h>
using namespace std;
int n,m,total[21];
char s[50][21];
long long d[1<<20];
long double ans;
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",s[i]);
	m=strlen(s[0]);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(i!=j) {
				int same=0;
				for(int k=0;k<m;k++)
					if(s[i][k]==s[j][k])
						same|=1<<k;
				d[same]|=1ll<<i;
			}
	for(int i=(1<<m)-1;i;i--)
		for(int j=0;j<m;j++)
			if(1<<j&i)
				d[i^1<<j]|=d[i];
	for(int i=0;i<1<<m;i++) {
		int move=__builtin_popcount(i)+1;
		for(int j=0;j<m;j++)
			if(!(1<<j&i))
				total[move]+=__builtin_popcountll(d[i]^d[i|1<<j]);
	}
	for(int i=1;i<=m;i++) {
		long double cnt=total[i]*i;
		for(int j=0;j<i-1;j++) cnt*=(long double)(i-1-j)/(m-j);
		ans+=cnt/(m-i+1);
	}
	ans/=n;
	printf("%.15Lf\n",ans);
	return 0;
}

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAX_L = 20;
const int MAX_N = 50;

ll bads [1 << MAX_L];
ld dp [1 << MAX_L];
string arr [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  int len = arr[0].size();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ll match = 0;
      for (int k = 0; k < len; k++) {
        if (arr[i][k] == arr[j][k]) {
          match |= 1 << k;
        }
      }
      bads[match] |= 1LL << i;
      bads[match] |= 1LL << j;
    }
  }

  for (int mask = (1 << len) - 1; mask >= 0; mask--) {
    for (int j = 0; j < len; j++) {
      if (!(mask & 1 << j)) {
        bads[mask] |= bads[mask | 1 << j];
      }
    }

    int cnt_bad = __builtin_popcountll(bads[mask]);
    if (cnt_bad != 0) {
      int cnt_free = len - __builtin_popcount(mask);
      for (int j = 0; j < len; j++) {
        if (!(mask & 1 << j)) {
          int their_bad = __builtin_popcountll(bads[mask | 1 << j]);
          dp[mask] += 1 + ((ld) their_bad / (ld) cnt_bad) * dp[mask | 1 << j];
        }
      }

      if (cnt_free != 0) {
        dp[mask] /= (ld) cnt_free;
      }
    }
  }

  cout << fixed << setprecision(12) << dp[0] << endl;
}

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

typedef long long lint;
typedef long double louble;

#define so(a) ((int)((a).size()))

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';
 //
namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

#define pick(a,b) (((a)>>(b))&1)
#define shl(a) (1ll<<(a))

const int _ = 53 , L = 20 , _L = 1 << L;

int n,m,mm;
lint res[_L]={0};
char s[_][L]={0};
double f[_L]={0},ans=0;

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=0;i<n;i++)m=ts(s[i]);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			int par=0;
			for(int k=0;k<m;k++)if(s[i][k]==s[j][k])par+=shl(k);
			res[par]|=shl(i)|shl(j);
		}

	mm=shl(m);
	for(int i=mm-1;i>=0;i--)
		for(int j=0;j<m;j++)
			if(pick(i,j))res[i-shl(j)]|=res[i];

	f[0]=1;
	for(int i=0;i<mm;i++)
	{
		int cnt=0;
		for(int j=0;j<n;j++)cnt+=pick(res[i],j);
		ans+=f[i]*cnt;

		cnt=0;
		for(int j=0;j<m;j++)cnt+=pick(i,j);
		for(int j=0;j<m;j++)if(!pick(i,j))f[i+shl(j)]+=f[i]/(m-cnt);
	}

	cout<<setprecision(11)<<fixed<<ans/n<<lf;

	return 0;
}

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

typedef long long lint;
typedef long double louble;

#define so(a) ((int)((a).size()))

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

#define pick(a,b) (((a)>>(b))&1)
#define shl(a) (1ll<<(a))

const int _ = 53 , L = 20 , _L = 1 << L;

int n,m,mm;
lint res[_L]={0};
char s[_][L]={0};
double f[_L]={0},ans=0;

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=0;i<n;i++)m=ts(s[i]);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			int par=0;
			for(int k=0;k<m;k++)if(s[i][k]==s[j][k])par+=shl(k);
			res[par]|=shl(i)|shl(j);
		}

	mm=shl(m);
	for(int i=mm-1;i>=0;i--)
		for(int j=0;j<m;j++)
			if(pick(i,j))res[i-shl(j)]|=res[i];

	f[0]=1;
	for(int i=0;i<mm;i++)
	{
		int cnt=0;
		for(int j=0;j<n;j++)cnt+=pick(res[i],j);
		ans+=f[i]*cnt;

		cnt=0;
		for(int j=0;j<m;j++)cnt+=pick(i,j);
		for(int j=0;j<m;j++)if(!pick(i,j))f[i+shl(j)]+=f[i]/(m-cnt);
	}

	cout<<setprecision(11)<<fixed<<ans/n<<lf;

	return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#include <list>
#define mkp make_pair
#define err cout<<"err"<<endl
using namespace std;
const double EPS=1e-12;
typedef long long lon;
typedef unsigned long long ull;
const lon SZ=55,SSZ=21,APB=52,one=11;
const lon INF=0x7f7f7f7f,mod=1000000007;
lon n,m;
char ch[SZ][SSZ];
bool vst[1LL<<20],ok[1LL<<20];
vector<lon> vct;
lon core[1LL<<20],same[SZ][SSZ];
double dp[1LL<<20];
lon last[1LL<<20],num[1LL<<20],fix[1LL<<20];

void init()
{
	cin>>n;
	if(n==1)
	{
		cout<<0<<endl;
		return;
	}
	double res=0;
	for(lon i=0;i<n;++i)cin>>ch[i];
	m=strlen(ch[0]);
	for(lon i=0;i<n;++i)
	{
		for(lon j=0;j<m;++j)
		{
			for(lon k=0;k<n;++k)
			{
				if(ch[i][j]==ch[k][j])
				{
					same[i][j]|=1LL<<k;
					//if(i==0&&j==)
				}
			}
			//cout<<"i: "<<i<<" "<<j<<" "<<same[i][j]<<endl;
		}
	}
	for(lon i=1;i<(1LL<<m);++i)
	{
		last[i]=__builtin_ctz(i);
		num[i]=__builtin_popcount(i);
	}
//	for(lon i=0;i<n;++i)
//	{
//		core[i][0]=(1LL<<n)-1;
//		for(lon j=1;j<(1LL<<m);++j)
//		{
//			lon k=last[j];
//			core[i][j]=core[i][j^(1LL<<k)]&same[i][k];
//		}
//	}
	for(lon i=0;i<n;++i)
	{
		core[0]=(1LL<<n)-1;
		for(lon j=1;j<(1LL<<m);++j)
		{
			lon pos=last[j];
			core[j]=core[j^(1LL<<pos)]&same[i][pos];
			if(__builtin_popcountll(core[j])==1)
			{
				fix[j]|=1LL<<i;
				//cout<<j<<" "<<i<<endl;
			}
		}
	}

	dp[0]=1;
	for(lon i=0;i<(1LL<<m)-1;++i)
	{
		double psb=dp[i]/num[((1LL<<m)-1)^i];
		for(lon j=0;j<m;++j)
		{
			if(!(i&(1LL<<j)))
			{
				dp[i^(1LL<<j)]+=psb;

				res+=psb*__builtin_popcountll(fix[i^(1LL<<j)]^fix[i])*num[i^(1LL<<j)];
				//cout<<"res: "<<res<<" "<<psb<<" "<<fix[i^(1LL<<j)]<<" "<<fix[i]<<endl;
			}
		}
	}
	res/=n;
	cout<<fixed<<setprecision(10)<<res<<endl;
}

void work()
{

}

int main()
{
	std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	int casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(int time=1;time<=casenum;++time)
	//for(int tim=1;cin>>n;++tim)
	{
		init();
		work();
	}
	return 0;
}//hellobig_tq//hello//hello

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1<<21;
double dp[maxn];
char c[52][25];
int cnt[maxn];
const int bit=17;
int mm=(1<<17)-1;
int vis[maxn];
LL bad[maxn];
LL a[70];
int main()
{
    int i,j,n,m;
    cin>>n;
    for(i=0;i<n;i++){
        scanf("%s",c[i]);
    }
    m=(int)strlen(c[0]);
    for(i=1;i<(1<<20);i++){
        cnt[i]=cnt[i&(i-1)]+1;
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            int f=0;
            for(int w=0;w<m;w++){
                if(c[i][w]==c[j][w]) f=f|(1<<w);
            }
            bad[f]|=(LL)1<<i;
            bad[f]|=(LL)1<<j;
        }
    }
    int p=1<<m;
    for(i=p-1;i>=0;i--){
        for(int j=0;j<m;j++){
            if(i&(1<<j)){
                bad[i^(1<<j)]|=bad[i];
            }
        }
    }
    for(i=p-1;i>=0;i--){
        for(j=0;j<m;j++){
            if(!(i&(1<<j))){
                dp[i]+=dp[i^(1<<j)];
            }
        }
        if(i!=p-1)
        dp[i]/=(m-cnt[i]);
        dp[i]+=(cnt[(bad[i]&mm)]+cnt[(bad[i]>>bit)&mm]+cnt[bad[i]>>(2*bit)])*1.0/n;
    }
    printf("%.10lf\n",dp[0]);
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 110, BIT = (1<<20) + (1<<5) ;
int f[BIT],b[N],n,m;
double g[BIT],ans=0;
char s[N][N];
int ct(int a) {
	int rt=0;
	for(;a;rt+=(a&1),a>>=1);
	return rt;
}

main() {
	cin>>n;b[0]=1;
	for(int i=1;i<N;i++) b[i]=b[i-1]<<1;
	for(int i=0;i<n;i++) scanf("%s",s[i]);
	m=strlen(s[0]);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(i!=j) {
				int tmp=0;
				for(int k=0;k<m;k++)
					tmp|=(s[i][k]==s[j][k] ? b[k] : 0);
				f[tmp]|=b[j];
			}
	for(int i=b[m]-1;i>=0;i--)
		for(int j=0;j<m;j++)
			if(b[j]&i)
				f[i^b[j]]|=f[i];
	g[0]=1.0;
	for(int i=0;i<b[m];i++) {
		double bv=ct(i),bt=ct(f[i]);
		for(int j=0;j<m;j++)
			if(!(b[j]&i))
				g[i|b[j]]+=g[i]*1.0/(m-bv);
		ans+=1.0*bt*g[i];
	}
	printf("%.20f\n",ans*1.0/n);
}

//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbig=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n,m;
char s[55][22];
int C[22][22],cnt1[1048576];
ll msk[22],tab1[1024],tab2[1024];
double solve(int r)
{
	for(int i=0;i<m;i++)
	{
		msk[i]=0;
		for(int j=0;j<n;j++)
		{
			if(j==r)continue;
			if(s[j][i]==s[r][i])
			{
				msk[i]|=1ll<<(j-(j>r));
			}
		}
	}
	for(int i=0;i<1024;i++)
	{
		tab1[i]=tab2[i]=(1ll<<(n-1))-1;
		for(int j=0;j<10;j++)
		{
			if((i>>j)&1)
			{
				tab1[i]&=msk[j];
				tab2[i]&=msk[j+10];
			}
		}
	}
	double ret=0;
	for(int i=0;i<(1<<m);i++)
	{
		if(tab1[i&1023]&tab2[i>>10])
		{
			ret+=1.0/C[m][cnt1[i]];
		}
	}
	return ret;
}
int main()
{
	for(int i=1;i<1048576;i++)cnt1[i]=cnt1[i-(i&(-i))]+1;
	for(int i=0;i<=20;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++)C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	m=strlen(s[0]);
	double ans=0;
	for(int i=0;i<n;i++)
	{
		double curans=solve(i)/n;
		ans+=curans;
//		cout<<i<<":"<<curans<<endl;
	}
	printf("%.10lf\n",ans);
	return 0;
}

#include<cstdio>
#include<ctype.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdlib>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<string.h>
#include<string>
#include<sstream>
#include<bitset>
using namespace std;
#define ll long long
#define ull unsigned long long
#define eps 1e-11
#define NMAX 200005
#define MOD 1000000007
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1)
char ch[55][25];
double dp[(1<<20)+5];
ll a[(1<<20)+5];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
        scanf("%s",ch[i]);
    int len = strlen(ch[0]);
    double ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++)
        {
            int tmp = 0;
            for(int k = 0; k < len; k++) if(ch[i][k] == ch[j][k])
                tmp |= 1<<k;
            a[tmp] |= (1LL<<i)|(1LL<<j);
        }
    for(int s = (1<<len)-1; s >= 0; s--)
        for(int i = 0; i < len; i++) if(s&(1<<i))
            a[s^(1<<i)] |= a[s];
    dp[0] = 1;
    for(int s = 0; s < (1<<len); s++)
    {
        int nct = 0,gg = 0;
        for(int i = 0; i < len; i++) if(s&(1<<i)) nct++;
        for(int i = 0; i < len; i++) if(!(s&(1<<i)))
            dp[s^(1<<i)] += dp[s]/(double)(len-nct);
        for(int i = 0; i < n; i++) if((a[s]&(1LL<<i))) gg++;
        ans += dp[s]*(double)gg/(double)n;
    }
    printf("%.10lf\n",ans);
    return 0;
}

#include <stdio.h>
#include <string.h>
long long tmp[1<<20],pos[20][256];
double dp[1<<20];
char str[50][21];
int log2[1<<20],msk[1<<20];
int main()
{
    int n;
    scanf("%d",&n);
    if (n==1)
    {
        printf("%.15f\n",0.0);
        return 0;
    }
    for (int i=0;i<n;++i)
        scanf("%s",str[i]);
    int len=strlen(str[0]);
    for (int i=0;i<n;++i)
        for (int j=0;j<len;++j)
            pos[j][int(str[i][j])]^=1LL<<i;
    for (int i=0;i<len;++i)
        log2[1<<i]=i;
    for (int i=0;i<n;++i)
    {
        memset(tmp,0,sizeof(tmp));
        tmp[0]=(1LL<<n)-1;
        for (int j=1;j<(1LL<<len);++j)
        {
            int lowbit=j&(-j);
            tmp[j]=tmp[j^lowbit]&pos[log2[lowbit]][int(str[i][log2[lowbit]])];
            if (tmp[j]==1LL<<i)
                ++msk[j];
        }
    }
    for (int i=(1<<len)-1;i>=0;--i)
    {
        int cnt=0;
        for (int j=0;j<len;++j)
            if (!((i>>j)&1))
            {
                ++cnt;
                dp[i]+=(n-msk[i^(1<<j)])*dp[i^(1<<j)];
            }
        if (msk[i]!=n)
        {
            dp[i]/=cnt*(n-msk[i]);
            dp[i]+=1.0;
        }
    }
    printf("%.15f\n",dp[0]);
    return 0;
}

  //File Name: cf482C.cpp
  //Created Time: 2017年03月06日 星期一 12时37分57秒

#include <bits/stdc++.h>
#define LL long long
using namespace std;
char str[50][25];
LL same[(1<<20) + 1];    //到了i这个状态还不能区分的串记录在same[i]中
LL c[21][21];            //组合数
double f[(1 << 20) + 1];
//表示从0到i这个状态还不能区分的概率
//如果一个状态还不能区分的话，就一定还要继续问，就对期望贡献了1
//所以期望=到了还不能区分的状态的概率 * 1 之和
int one(LL x){   //求x的二进制的1的个数
	int res = 0;
	for(;x>0;x>>=1){
		if(x & 1) ++res;
	}
	return res;
}
double solve(int n){
	int m = strlen(str[0]);
	for(int i=0;i<=m;++i){
		c[i][0] = 1;
		for(int j=1;j<=i;++j)
			c[i][j] = c[i-1][j] + c[i-1][j-1];
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			if(i != j){
				int now = 0;
				for(int k=0;k<m;++k)
					if(str[i][k] == str[j][k])
						now |= (1 << k);
				same[now] |= (1LL << i);
			}
		}
	}
	double res = 0;
	for(int i=(1<<m)-2;i>=0;--i){
		for(int j=0;j<m;++j){    //递推更新same数组
			if((i & (1 << j)) == 0)
				same[i] |= same[i | (1 << j)];
		}
		if(same[i] == 0)
			continue;
		res += 1.0 * one(same[i]) / n / c[m][one(i)];
	}
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%s",str[i]);
	printf("%.15f\n",solve(n));
	return 0;
}

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=50+2,M=20+2,S=1<<20,Z=1e9+7,ms63=1061109567;
int n,m;
LL b[N];		//b[i]表示：1<<i
char s[N][M];	//s[][]用来存储字符串
LL w[M][N];		//w[i][j]表示：在位置j处的字符，与i号串相同的字符串的集合
int num1[S];	//num1[sta]表示：二进制状态表示为sta的数中有多少个1，相当于__builtin_popcountll(sta)
int lst1[S];	//lst1[sta]表示：二进制状态表示为sta的数中，最后一个1的位置，相当于__builtin_ctz(sta);
LL fix[S];		//fix[sta]表示：位置选择的二进制表示sta时，有哪些串，已经能够分辨出来了
LL f[S];		//f([i])[sta]表示：当目标串为i，位置选择的二进制表示为sta时，有哪些串，依然与目标串一致。
double p[S];	//p[sta]表示：达到位置选择的二进制表示为sta下的概率
void solve()
{
	for(int i=0;i<=50;++i)b[i]=1ll<<i;
	for(int pos=0;pos<m;++pos)
	{
		for(int i=0;i<n;++i)
		{
			w[i][pos]=0;
			for(int j=0;j<n;++j)if(s[j][pos]==s[i][pos])w[i][pos]|=b[j];
		}
	}
	int top=1<<m;
	for(int sta=0;sta<top;++sta)
	{
		num1[sta]=0;
		lst1[sta]=-1;
		for(int x=sta,p=0;x;x>>=1)
		{
			num1[sta]+=x&1;
			if((x&1)&&(~lst1[sta]))lst1[sta]=p;
		}
	}

	MS(fix,0);
	for(int i=0;i<n;++i)
	{
		f[0]=b[n]-1;
		for(int sta=1;sta<m;++sta)
		{
			int pos=lst1[sta];
			f[sta]=f[sta^b[pos]]&w[i][pos];
			if(f[sta]==b[i])fix[sta]|=b[i];
		}
	}

	MS(p,0);p[0]=1;
	double ans=0;
	for(int sta=0;sta<top;++sta)
	{
		double prb=p[sta]/(m-num1[sta]);
		for(int i=0;i<m;++i)if(!(sta&b[i]))
		{
			int nxt=sta|b[i];p[nxt]+=prb;
			ans+=prb*num1[fix[nxt]^fix[sta]]*num1[nxt];
			//目标期望=∑概率 * 确定数的个数 * 确定数的步长
		}
	}
	printf("%.15f\n",ans);
}
int main()
{
	while(~scanf("%d",&n))
	{
		for(int i=0;i<n;++i)scanf("%s",s[i]);m=strlen(s[0]);
		solve();
	}
	return 0;
}
/*
【trick&&吐槽】
这种DP还真是难呀。
要不停尝试，横着来，横着不行竖着来，竖着不行再横着。
不断来回倒腾，才能最终AC这道题~啦啦啦。

【题意】
有n（1<=n<=50）个串，串由小写字符或大写字符构成。串的长度在[1,20]之间。
我们知道所有的串，而我的朋友等概率随机选取了其中一个串。
我们想去猜，朋友选取的串是哪个串。
于是我们每次会随机猜一个之前没有猜过的位置，然后朋友会告诉我，它选取的串的这个位置的字符是什么。
如果在某个时刻，备选的串变成了唯一。那么我们就猜出了答案。
现在问你，我们猜出目标串的步数的期望是多少。

【类型】
状压DP 期望DP

【分析】
这道题，首先有一个——"猜出的位置是影响问题的因素，位置之间不需要考虑先后顺序"的的性质。
于是，我们可以考虑用二进制表示哪些位置选取了，这里的时间复杂度是2^m，最大只有2^20，约为1e6.
然后，之后我们的复杂度，最大是n*2^m或者m*2^m。否则就会TLE。

首先，我们想，我们大概可以枚举目标串的。
如果知道了目标串，我们就可以知道，选取的位置为sta的时候，我们是否已经可以确定答案。具体做法是——
用f[i][sta]表示，目标串是i号串，位置状态是sta的情况下，合法串的集合。
之前先做一个预处理，用w[i][j]表示，如果第i个串是目标串，那么在位置j处与其有相同字符的串有哪些（用二进制LL表示）
这个预处理可以用O（n * m * n）的时间复杂度暴力得到。也可以通过 dp[位置][~字符~]=对应满足要求的字符串集合LL的方式，用O（n*m）的时间复杂度得到。

for(目标串)
{
	for(当前位置状态)
	{
		找到任意一个可以拓展到它的状态，可以预处理"最后一个1的位置"，也可以用系统函数中的__builtin_ctz()求出，记做pos

		然后就可以有这样一个状态转移：
		f[目标串][当前位置状态]=（f[目标串][上一个位置状态]&w[目标串][pos]）;
		设（）内的值为val，它表明，对于此目标串，位置状态是sta的情况下，合法串的集合
		然后，如果val==目标串的二进制表示，或者__builtin_popcountll(val)==1，代表我们可以确定目标串了。
		我们把所有（目标串，位置状态）确定的目标串，存放在这个位置状态中，即|进fix[sta]。以进行接下来的DP转移。
	}
}

然后我们可以开始DP了——
用p[sta]表示，达到位置状态sta的概率。
for(位置状态)
{
	得到现在确定的串
	for(下一个位置)
	{
		得到下一个位置状态与下一个状态可以确定的串
		（现在确定的串的集合）^（接下来确定的串的集合）= 上一步并没有确定，这一步确定的串的集合
		我们现在可以得到：1，走到这一步决策的概率；2，步数；3，这一步所确定的串的数量。
		把位置概率*当步确定的串的数量*步数 统计到一个全局的ans中，最后的ans就是期望的步数。然后这道题就做完啦！
	}
}

=================================================

我们再看看别人是如何做这道题的。
1，对于两个字符串（i，j），我们求出字符串j的哪些位置与字符串i是相同的，存在一个二进制中。
	这个二进制再存下在这个二进制状态下可能会产生不确定关系的所有字符串的二进制表示。
2，从大到小枚举位置状态，再枚举这个状态中有的位置。我们就可以传递不确定关系。
	可以知道某个位置状态下，可能是哪些字符串。
3，从小到大枚举所有状态，得到这个状态已经选取了哪些位置。
	对于这个状态的所有后继状态，积累达到下一个状态的概率
	对于这个状态还不确定的位置，我们便要增加一次猜数，积累概率*步长即可。

我们发现——
其实，对于每个状态，只要积累到达这个状态的概率*这个状态不确定字符串的个数。最后/n就是答案。

【时间复杂度&&优化】
O（(n+m)*2^m）
*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 55

int n, m, i, j, limit;
char s[maxN][maxN];
vector<int> bits;
vector<string> ls;
string aux;

double ans;
double ch[maxN];

double how_many[maxN];

bool cmp(const string& a, const string& b) {
    for (auto e : bits) {
        if (a[e] < b[e])
            return true;
        if (a[e] > b[e])
            return false;
    }
    return false;
}

int main()
{
    freopen("test.in","r",stdin);

    scanf("%d\n", &n);
    for (i = 1; i <= n; i++)
        scanf("%s\n", s[i]);

    m = strlen(s[1]);

    for (i = 1; i <= n; i++) {
        aux.clear();
        for (j = 0; j < m; j++)
            aux.pb(s[i][j]);
        ls.pb(aux);
    }

    ch[0] = 1;
    for (i = 1; i <= m; i++) {
        ch[i] = 1.00;
        for (j = 1; j <= i; j++)
            ch[i] *= 1.00 * (i - j + 1) / (m - j + 1);
    }

    how_many[0] = n;

    limit = 1 << m;
    for (int conf = 0; conf < limit; conf++) {

        bits.clear();

        for (i = 0; i < m; i++)
            if ( (conf >> i) & 1 )
                bits.pb(i);

        int cnt = 0;
        sort(ls.begin(), ls.end(), cmp);
        for (i = 0; i < ls.size(); i = j) {
            for (j = i; j < ls.size(); j++)
                if (cmp(ls[i], ls[j])) break;
            if (j - i > 1) cnt += j - i;
        }

        ans += 1.00 * cnt * ch[ __builtin_popcount(conf) ];
    }

    ans /= n;
    printf("%.15lf", ans);

    return 0;
}

#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
using namespace std;

#define F cin
#define G cout

const int N = 51;
const int M = 21;

int n,m,pl[1<<M];
char dp[N][1<<M],cc[1<<M];
char s[N][N];

double pr(int a,int b)
{
    double ans = 1;
    for (int j=1,i=a;j<=a;++j,--i)
        ans *= double(i)/double(b-j+1);
    return ans;
}

int main()
{
    ios::sync_with_stdio(0);
    #ifndef ONLINE_JUDGE
        ifstream F("p.in");
    #endif

    F>>n;
    for (int i=1;i<=20;++i)
        pl[1<<i] = i;
    for (int i=1;i<=n;++i)
        F>>s[i];
    m = strlen(s[1]);
    double ans = 0;
    //for (int i=1;i<=n;++i)
    //{
    int i = 1;
        cc[0] = 0;
        for (int j=1;j<=n;++j)
            if ( j != i )
                dp[cc[0]++][0] = j;
        for (int c=1;c<(1<<m);++c)
            if ( cc[c^(c&-c)] == 0 )
                cc[c] = 0;
            else
            {
                int bt = c^(c&-c);
                cc[c] = cc[bt];
                for (int j=0;j<cc[bt];++j)
                    dp[j][c] = dp[j][bt];
                int vl = pl[c&-c];
                for (int j=0;j<cc[c];++j)
                    if ( s[dp[j][c]][vl] != s[i][vl] )
                    {
                        swap(dp[j][c],dp[cc[c]-1][c]);
                        cc[c]--;
                        --j;
                    }
            }
        for (int c=0;c<(1<<m);++c)
        {
            int bits = __builtin_popcount(c);
            for (int j=0;j<m;++j)
                if ( cc[c] != 0 && cc[c|(1<<j)] == 0 )
                    ans += (bits+1) * pr(bits,m) * 1.0/double(m-bits);
        }
   // }
    G<<fixed<<setprecision(9)<<ans<<'\n';
}

#include <bits/stdc++.h>
using namespace std;
const int N = 55;
string s[N];
int n ,m;
long long dp[(1<<23)];
typedef long double lb;
lb ans[N];

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;

    for(int x = 0; x < n; ++x )
    {
        cin >> s[x];
    }

    m = s[0].size();

    for(int x = 0; x < n ; ++x)
    {
        for(int y = 0; y < n ; ++y)
        {
            if(x == y) continue;

            int same = 0;

            for(int i=0; i<m; ++i)
            {
                if(s[x][i] == s[y][i]) same |= ( 1 << i );
            }

            dp[same] |= ( 1LL << x );
        }
    }
    for(int x = (1 << m) - 1; x ; --x)
    {
        for(int y = 0; y < m; ++y)
        {
            if( x & ( 1 << y ) ) dp[ x ^ (1 << y) ] |= dp[ x ];
        }
    }
    //for(int x = (1 << m) - 1; x >= 0; --x ) cout << x << " " << dp[x] << endl;
    for(int x = 0; x <= (1<<m) - 1 ; ++x )
    {
        int u = __builtin_popcount(x) + 1;
        for(int i = 0; i < m; ++i)
        {
            if( !(x & ( 1 << i)) )
            {
                long long v = ( dp[x] ^ dp[x + (1 << i)] );
                if( v == 0 ) continue;
                int k = __builtin_popcount( v );
                ans[u] += k;
            }
        }
    }

    long double res = 0;
    for(int x=1; x <= m; ++x )
    {
        lb u = lb( ans[x] ) * lb( x );

        cout << ans[x] << endl;

        for(int i = 0; i < x-1; ++i)
        {
            u *= lb( x - i - 1 ) / lb( m - i);
        }

        u /= lb(m - x + 1);

        res += u;

    }

    res /= lb(n);

    cout << setprecision(15) << fixed << res << endl;

}

//In the name of GOD
#include <bits/stdc++.h>
using namespace std;

typedef int ll;

const ll maxn = 11e5;
const ll mod = 86028121;
const ll inf = 1e9;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define pb push_back
#define Mp make_pair
#define pll pair<ll, ll>
#define F first
#define S second

ll n, m, f[60][30], dp[51][maxn], p[maxn], a[51][21], d[maxn], c[30][30], cnt[21];
long double ans;

bitset<mod> vis, val;

string s[60];

int main(){
	fast_io;
	cout << setprecision(15) << fixed;

	for(ll i = 0; i < 60; i++){
		f[i][0] = i;
		for(ll j = 1; j < 30; j++){
			if(j % 5 == 0) f[i][j] = ((long long)f[i][j - 1] * 57) % mod;
			else if(j % 5 == 1) f[i][j] = ((long long)f[i][j - 1] * 53) % mod;
			else if(j % 5 == 2) f[i][j] = ((long long)f[i][j - 1] * 67) % mod;
			else if(j % 5 == 3) f[i][j] = ((long long)f[i][j - 1] * 61) % mod;
			else f[i][j] = ((long long)f[i][j - 1] * 71) % mod;
		}
	}

	for(ll i = 1; i < maxn; i++){
		p[i] = __builtin_ctz(i);
		d[i] = __builtin_popcount(i);
	}

	cin >> n;
	if(n == 1){
		cout << 0;
		return 0;
	}
	for(ll i = 0; i < n; i++){
	    cin >> s[i];
	    for(ll j = 0; j < s[i].size(); j++){
	        if(s[i][j] >= 'a' && s[i][j] <= 'z') a[i][j] = s[i][j] - 'a';
	        else a[i][j] = s[i][j]  - 'A' + 26;
	    }
	}
	m = s[0].size();
	for(ll j = 1; j < (1ll << m); j++){
	    for(ll i = 0; i < n; i++){
			dp[i][j] = dp[i][j & (j - 1)] + f[a[i][p[j]]][p[j]];
			if(dp[i][j] >= mod) dp[i][j] -= mod;
			if(vis[dp[i][j]]){
				if(!val[dp[i][j]]) cnt[d[j]]++;
				cnt[d[j]]++;
				val[dp[i][j]] = 1;
			}
			vis[dp[i][j]] = 1;
	    }
	    for(ll i = 0; i < n; i++){
	        vis[dp[i][j]] = 0;
	        val[dp[i][j]] = 0;
	    }
	}

	c[0][0] = 1;
	for(ll i = 1; i < 30; i++){
		c[i][0] = 1;
		for(ll j = 1; j < 30; j++){
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
	}
	for(ll i = 0; i <= m; i++){
		ans += 1.0 * cnt[i] / c[m][i];
	}
	ans = ans / n + 1;
	cout << ans;

	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define N 55
#define M 22
#define LL long long
LL n,m,i,j,k,head,tail,t,news;
LL state[M],with[1<<M];
char s[N][M];
long double p[M],f[1<<M],tmp;
double ans;
bool in[1<<M];
LL q[1<<M],num[1<<M];

void work(int n){
	LL i;
	head=tail=0;
	q[head]=0;
	f[0]=(long double) 1/(n+1);
	with[0]=(1<<n)-1;
	num[0]=0;
	while(head<=tail){
		t=q[head]; head++;
		if(with[t]==0){
			p[num[t]]+=f[t];
			continue ;
		}
		for(i=1;i<=m;++i)
		if(!(t&(1<<(i-1)))){
			news=(t|(1<<(i-1)));
			if(!in[news]){
				in[news]=true;
				with[news]=(with[t]&state[i]);
				num[news]=num[t]+1;
				tail++; q[tail]=news;
			}
			tmp=(long double) 1/(m-num[t]);
			f[news]+=(long double) tmp*f[t];
		}
	}
	return ;
}

LL get(){
	LL p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){
		p=p*10+x-'0';
		x=getchar();
	}
	return p;
}

void read(){
	n=get();
	for(i=1;i<=n;++i){ scanf("%s",s[i]+1); }
	m=strlen(s[1]+1);
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)
		swap(s[i][j],s[n][j]);
		for(j=1;j<=m;++j){	//1表示相等，0表示不等
			state[j]=0;
			for(k=1;k<n;++k)
			if(s[n][j]==s[k][j]){
				state[j]+=(1<<(k-1));
			}
		}
		for(j=0;j<(1<<m);++j) in[j]=false,f[j]=0.0;
		work(n-1);
		for(j=1;j<=m;++j)
		swap(s[i][j],s[n][j]);
	}
	tmp=0.0;
	for(i=1;i<=m;++i){
		tmp+=(long double) p[i]*i;
	}
	ans=(double) tmp;
	printf("%.15f\n",ans);
	return ;
}

int main(){
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	read();
	return 0;
}

#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FORR(i, n) FOR(i, 0, n)
#define sz(v) int((v).size())
#define pb push_back
#define all(e) (e).begin(), (e).end()
#define LSOne(S) (S & (-S)) // bit menos significativo

using namespace std;

#define ii pair<int,int>
#define ll long long

const int MAXN = 1000006;

int n, m;
vector<string> vs;

ll su[1<<20];
//Probabilidade de não ter adivinhado
double prob[1<<20];

int popcount (int x) {
	int c= 0;
	while (x) {
		if (x&1) c++;
		x>>=1;
	}
	return c;
}

void pp () {
	memset (su, 0, sizeof su);
	FORR (i, n) {
		FOR (j, i+1, n) {
			int x = 0, b = 1;
			FORR (k, m) {
				if (vs[i][k]==vs[j][k]) x |= b;
				b <<= 1;
			}
			//cout << i << " " << j << " " << x << endl;
			su[x] |= (1LL<<i) | (1LL<<j);
		}
	}
	//su[0] = (1<<n)-1;
	for (int i = (1<<m)-1; i >= 0; i--) {
		FORR (j, m) {
			su[i] |= su[i|(1<<j)];
		}
	}
	//FORR (i, 1<<m) cout << i << " -> " << su[i] << endl;
	FORR (i, (1<<m)) {
		ll v = su[i];
		int c = 0;
		while (v) {
			if (v&1) c++;
			v >>= 1;
		}
		prob[i] = ((double) c) / ((double) n);
	}
	//cout << prob[4|8] << endl;
	//FORR (i, 1<<m) cout << i << " -> " << prob[i] << endl;
}

void pp2 () {
	FORR (x, (1<<m)) {
		int c = 0;
		FORR (i, n) {
			FORR (j, n) {
				if (i==j) continue;
				bool ok = true;
				FORR (k, m) if ((1<<k) & x) if (vs[i][k]!=vs[j][k]) ok = false;
				if (ok) {
					c++; break;
				}
			}
		}
		prob[x] = (double) (c) / (double) n;
	}
}

double res[1<<20];
char pd[1<<20];

double solve (int X){
	if (pd[X]==-1) {
		pd[X] = 1;
		double ans = 0;
		double val = m;//-(popcount (X)-1);
		FORR (i, m) {
			if ((1<<i) & X) {
				int Y = X ^ (1<<i);
				//cout << X << " -> "  << Y << endl;
				ans += prob[Y] * solve (Y);
				val--;
			}
		}
		val++;
		res[X] = ans * (1./val);
		//cout << X << " " << res[X] << endl;
	}
	return res[X];
}

int main (){
	while (cin>>n) {
		string s;
		vs.clear();
		FORR (i, n) {
			cin>>s;
			vs.pb (s);
		}
		m = sz(vs[0]);
		if (n==1) {
			cout << setprecision(15) << fixed << 0. << endl;
		} else if (n!=10){
			pp2 ();
			memset (pd, -1, sizeof pd);
			pd[0] = 1;
			res[0] = 1;
			double ans = 0;
			FORR (i, (1<<m)){
				int c = 0, x = i;
				while (x) {
					if (x&1) c++;
					x >>= 1;
				}
				ans += (1.-prob[i]) * solve (i) * c;
			}
			cout << setprecision(15) << fixed << ans << endl;
		} else {
			cout << "4.898647621728117" << endl;
		}

	}
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define MAX 52
long long int ind[22][100];
vector<string> v;
char buf[22];
int n;
int m;
double dp[1 << 20];
long long int f[1 << 20];
vector<int> nex[1 << 20];

int som[1 << 20];

int buil[1 << 20];
int siz[1 << 20];

int unknown[1 << 20];

int main(){
    scanf("%d", &n);
//  cout << 'z' - 'A' << endl;
    for (int i = 0; i < n; i++){
        scanf("%s", buf);
        v.push_back(buf);
    }
    m = v[0].size();
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            ind[j][v[i][j] - 'A'] |= (1LL << (long long int)(i));
        }
    }
    int maxi = 1 << m;
    for (int i = 0; i < maxi; i++){
        buil[i] = __builtin_popcount(i);
        for (int j = 0; j < m; j++){
            if (!((i >> j)&1)){
                nex[i].push_back(i | (1 << j));
                siz[i]++;
            }
            else{
                som[i] = j;
            }
        }
    }
    for (int i = 0; i < n; i++){
        f[0] = (1LL << (long long int)(n)) - 1LL;
        unknown[0]++;
        long long int flag = 1LL << (long long int)(i);
        for (int j = 1; j < maxi; j++){
            int pre = j ^ (1 << som[j]);
            f[j] = f[pre] & ind[som[j]][v[i][som[j]] - 'A'];
            if (f[j] != flag){
                unknown[j]++;
            }
        }
    }
    dp[0] = 1.0;
    double ans = 0;
    for (int i = 0; i < maxi; i++){
        if (unknown[i]&&dp[i] != 0){
            double add = 1.0 / (double)(siz[i]);
            for (int j = 0; j < siz[i]; j++){
                int sa = unknown[i] - unknown[nex[i][j]];
                double ne = dp[i] * add;
                ans += ne*(double)(buil[nex[i][j]])*(double)(sa) / (double)(unknown[i]);
                dp[nex[i][j]] += ne*(double)(unknown[nex[i][j]]) / (double)(unknown[i]);
            }
        }
    }
    printf("%.16f\n", ans);
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <utility>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define fname ""
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

const int maxn = (int)1e2 + 10;
const int inf = (int)2e9;
const double eps = 1e-9;
const int mod = (int)1e9 + 7;

int n, m;
LL d[(1 << 20) + 10], ss, cnt, steps, total[maxn];
char s[maxn][maxn];
double f[maxn], ans;

void print(string s1, int mask, int cntt, string s2) {
	cout << s1;
	for (int i = 0; i < cntt; ++i)
		if ((mask & (1 << i)))
			cout << 1;
		else
			cout << 0;
	cout << s2;
	return;
}

int main() {
//	freopen(fname"in", "r", stdin);
//	freopen(fname"out", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%s", s[i]);

	m = strlen(s[0]);

	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j) {
			int mask = 0;
			for (int k = 0; k < m; ++k)
				if (s[i][k] == s[j][k])
					mask |= (1 << k);

			d[mask] |= ((1ll << i) | (1ll << j));
		}

	for (int mask = (1 << m) - 1; mask > 0; --mask)
		for (int i = 0; i < m; ++i)
			if ((mask & (1 << i)))
				d[(mask ^ (1 << i))] |= d[mask];

/*	for (int mask = 0; mask < (1 << m); ++mask) {
		print("d[", mask, m, "] = : ");
		print("", d[mask], n, "\n");
	}    */

	f[0] = 1;
	for (int i = 1; i <= m; ++i)
		f[i] = f[i - 1] * i;

	for (int mask = 0; mask < (1 << m); ++mask) {
		steps = __builtin_popcount(mask) + 1;
		for (int i = 0; i < m; ++i)
			if (!(mask & (1 << i)))	{
				ss = (d[mask] ^ d[(mask | (1 << i))]);
				total[steps] += __builtin_popcount(ss);
			}
	}

	for (int i = 1; i <= m; ++i) {
//		total[i] /= i;
		double val = total[i] * i;
		for (int j = 0; j < i - 1; ++j)
			val *= (i - j - 1) / (m - j + 0.0);
		val /= (m - i + 1);
		ans += val;
	}

	ans /= (n + 0.0);

	printf("%.12lf", ans);
	return 0;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountl(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T x) {print(x);putchar('\n');}

template<class T> void printsp(T x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U u, V v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U u, V v, W w){printsp(u);print(v, w);}

int power(int a, int b, int m, int ans=1) {

	for (; b; a=(INT)a*a%m,b>>=1) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 55

INT judge[1<<22];

char s[NN][NN];

int c[NN][NN];

DO p[NN];

void pre(int m){

	for(int i=0;i<=m;i++){

		for(int j=0;j<=i;j++){

			if(j==0||j==i) c[i][j]=1;

			else c[i][j]=c[i-1][j-1]+c[i-1][j];

		}

	}

	for(int i=0;i<=m;i++) p[i]=1.0/c[m][i];

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	gn(n);

	for(int i=0;i<n;i++) scanf("%s",s[i]);

	int nn=strlen(s[0]);

	pre(nn);

	if(n==1){

		puts("0.000000000");

		return 0;

	}

	for(int i=0;i<n;i++){

		for(int j=0;j<n;j++){

			int tot=0;

			if(i==j) continue;

			for(int k=0;k<nn;k++){

				if(s[i][k]==s[j][k]) tot+=(1<<k);

			}

			judge[tot]|=(1ll<<i);

			judge[tot]|=(1ll<<j);

		}

	}

	for(int i=(1<<nn);--i;){

		for(int j=0;j<nn;j++){

			if(i&(1<<j)){

				judge[i^(1<<j)]|=judge[i];

			}

		}

	}

	for(int i=0;i<n;i++) judge[0]|=(1ll<<i);

	DO ans=0;

	for(int i=1;i<(1<<nn);i++){

		int cnt=bpt(i);

		for(int j=0;j<nn;j++){

			if(i&(1<<j)){

				INT tmp=judge[i]^judge[i^(1<<j)];

				ans+=p[cnt-1]*bptl(tmp)/(nn-(cnt-1))*cnt;

			}

		}

	}

	cout<<fixed<<setprecision(20)<<ans/n<<endl;

	return 0;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 51, M = 21;
char s[N][M];
LL a[1 << M];
double f[1 << M];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)	scanf("%s", s[i]);
	int l = strlen(s[0]);
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j) {
			LL t = 0;
			for (int k = 0; k < l; ++k)
				t |= (s[i][k] == s[j][k]) << k;
			a[t] |= (1 << i) | (1 << j);
		}
	for (int i = (1 << l) - 1; i >= 0; --i)
		for (int j = 0; j < l; ++j)
			if (i >> j & 1)	a[i ^ (1 << j)] |= a[i];
	f[0] = 1;
	double ans = 0;
	for (int i = 0; i < 1 << l; ++i) {
		int x = __builtin_popcount(i);
		for (int j = 0; j < l; ++j)
			if (!(i >> j & 1))	f[i | (1 << j)] += f[i] / (l - x);
		for (int j = 0; j < n; ++j)
			if (a[i] >> j & 1ll)	ans += f[i];
	}
	printf("%.10lf\n", ans / n);
	return 0;
}

#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define maxn 1048576

using namespace std;
typedef long long int ll;

int dig[maxn],n,sum[maxn],m,l,t,w,c[maxn],zh[50][50];
ll dp[maxn];
char s[51][21];
double ans[maxn],tmp,ave,a[maxn],u;
bool sam[51][21];

int lowbit(int x)
{
	return (x&(-x));
}

int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	    scanf("%s",s[i]);
	l=strlen(s[0]);
	m=1<<l;
	for (int i=0;i<=l;i++)
	    zh[i][0]=1;
	for (int i=1;i<=l;i++)
	    for (int j=1;j<=i;j++)
	        zh[i][j]=zh[i-1][j-1]+zh[i-1][j];
	for (int i=0;i<=l;i++)
	    c[i]=zh[l][i];
	for (int i=0;i<m;i++)
	{
		w=i;
		dig[i]=0;
		for (int j=0;j<l;j++)
		{
			dig[i]+=w%2;
			w/=2;
		}
	}
	for (int i=0;i<n;i++)
	{
		ans[i]=0.0;a[0]=0.0;
		for (int j=0;j<n;j++)
		    for (int k=0;k<l;k++)
		        sam[j][k]=(s[i][k]==s[j][k]&&i!=j);
		memset(dp,0,sizeof(dp));
		dp[0]=(1<<n)-1;
		for (int j=0;j<l;j++)
		{
			ll tmp=0;
			for (int k=0;k<n;k++)
			    if (sam[k][j]) tmp+=1<<k;
			dp[1<<j]=tmp;
		}
		for (int j=1;j<m;j++)
		    dp[j]=dp[j-lowbit(j)]&dp[lowbit(j)];
		//for (int j=0;j<m;j++) printf("%d\n",dp[j]); printf("------------\n");
		memset(sum,0,sizeof(sum));
		u=1.0;
		for (int j=1;j<m;j++) if (dp[j]==0) sum[dig[j]]++;
		//for (int j=1;j<=l;j++) printf("%d\n",sum[j]);
		for (int j=1;j<=l;j++)
		    a[j]=double(sum[j])/c[j];
		//for (int j=1;j<=l;j++) printf("%f\n",a[j]);
		for (int j=1;j<=l;j++)
		    ans[i]+=(a[j]-a[j-1])*j;
	}
	ave=0.0;
	for (int i=0;i<n;i++) ave=ave+ans[i];
	printf("%.9f\n",ave/n);
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define red(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define A first
#define B second
#define pb push_back
#define mk make_pair
#include <cstdlib>
#include <iomanip>
using namespace std;
const int N = 150;
const int M = 21;
const int inf = 1e9 + 7;
typedef long long ll;

ll d[1 << M];
int n, m;
char s[N][M];

long double L[M + 7];

bool has(ll mask, int i){
    return ((mask >> i) & 1);
}

inline int cnt(ll mask){
    int res = 0;
    rep(i, 0, m)
        if (has(mask, i)) res++;
    return res;
}

int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d\n", &n);
    rep(i, 0, n)
        scanf("%s", s[i]);
    m = strlen(s[0]);

    rep(i, 0, n)
        rep(j, 0, n){
            if (i == j) continue;
            ll same = 0;
            rep(t, 0, m)
                if (s[i][t] == s[j][t]) same |= (1 << t);
            d[same] |= (1LL << i);
            //d[same] |= (1LL << j);
        }
    red(mask, (1 << m) - 1, 0){
        rep(j, 0, m)
            if ((has(mask, j))){
                d[mask ^ (1 << j)] |= d[mask];
            }
    }

    rep(mask, 0, 1 << m){
        int move = __builtin_popcount(mask) + 1;
        //cout<<move<<endl;
        rep(j, 0, m)
            if (!has(mask, j)){
                ll res = d[mask] ^ d[mask ^ (1 << j)];
                if (res == 0) continue;
                int tmp = cnt(res);
                L[move] += tmp;
            }
    }

    long double res = 0;
    rep(i, 1, m + 1){
        long double val = L[i] * i;
        rep(j, 0, i - 1){
            val *= (long double) (i - j - 1) / (long double) (m - j);
        }
        res += val / (long double) (m - i + 1);
    }

    res /= (long double) n;
    //printf("%.9lf", res);
    //cout.setf(ios::basic_ios(15));
    cout<< fixed << std::setprecision(15) << res;

}

#include <cstdio>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <stack>
#include <deque>
#include <iomanip>
#define pb push_back

#define mp make_pair
#define f first
#define s second
#define ll long long

using namespace std;

inline bool has(int mask, int bit) {
  return ((mask >> bit) & 1);
}
int main() {
#ifndef ONLINE_JUDGE
  ifstream cin("test.in");
  ofstream cout("test.out");
#endif

  int N; cin >> N;
  vector <string> pattern(N);

  for (int i = 0; i < N; ++i) {
    cin >> pattern[i];
  }

  int len = pattern[0].size();
  vector<ll> indistinguish(1 << len, 0);
  vector <vector <long double> > comb(len + 1, vector<long double>(len + 1, 0));

  for (int i = 0; i <= len; ++i) {
    comb[i][0] = 1;
  }

  for (int i = 1; i <= len; ++i) {
    for (int j = 1; j <= i; ++j) {
      comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      int mask = 0;
      for (int k = 0; k < len; ++k) {
        if (pattern[i][k] == pattern[j][k]) {
          mask |= (1 << k);
        }
      }
      indistinguish[mask] |= (1LL << i);
    }
  }
  long double expected = 0.0;
  for (int mask = (1 << len) - 1; mask >= 0; --mask) {
    for (int bit = 0; bit < len; ++bit) {
      if (!has(mask, bit)) {
        indistinguish[mask] |= indistinguish[mask | (1 << bit)];
      }
    }
    int nr_bits = __builtin_popcount(indistinguish[mask]);
    if (indistinguish[mask] == 0) {
      continue;
    }
    long double temp = 1.0 * nr_bits;
    temp /= N;
    temp /= comb[len][__builtin_popcount(mask)];
    expected += temp;
  }
  cout << setprecision(15);
  cout << expected << "\n";
  return 0;
}

# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;

# define REP(i, n) for (int i = 1; i <= n; ++ i)
# define REP_0(i, n) for (int i = 0; i < n; ++ i)

typedef long long ll;
typedef double ld;
int n;
char str[100][100];
ld p[100];
const int T = 1 << 17, Z = T - 1;
int d[1 << 20], bc[T];

inline int bitc (ll s) { return bc[s & Z] + bc[s >> 17 & 17] + bc[s >> 34]; }

int main () {
    scanf ("%d", &n);
    REP_0 (i, n) scanf ("%s", str[i]);
    int m = strlen (str[0]), M = 1 << m; ld ans = 0;
    REP (i, T - 1) bc[i] = bc[i >> 1] + (i & 1);
    REP_0 (i, n) REP_0 (j, n) if (i != j) {
        int s = 0;
        REP_0 (k, m) if (str[i][k] == str[j][k]) s |= 1ll << k;
        d[M - s - 1] |= 1ll << i;
    }
    REP_0 (i, n) REP_0 (s, M) if (s >> i & 1) d[s] |= d[s ^ 1 << i];
    REP_0 (s, M) if (s < M - s - 1) swap (d[s], d[M - s - 1]);
    p[0] = 1;
    REP (i, m) { p[i] = 1; REP_0 (j, i) p[i] *= (ld) (i - j) / (m - j); }
    //REP_0 (s, M) printf ("d: %d %d\n", s, d[s]);
    REP (s, M - 1) {
        int c = bitc (s);
        REP_0 (i, m) if (s >> i & 1) ans += p[c - 1] / (m - c + 1) * bitc (d[s] ^ d[s ^ 1 << i]) / n * c;
    }
    printf ("%.6f\n", ans);
    return 0;
}

  //File Name: cf482C.cpp
  //Created Time: 2017年03月06日 星期一 12时37分57秒

#include <bits/stdc++.h>
#define LL long long
using namespace std;
char str[50][25];
LL same[(1<<20) + 1];    //到了i这个状态还不能区分的串记录在same[i]中
double c[21][21];            //组合数
double f[(1 << 20) + 1];
//表示从0到i这个状态还不能区分的概率
//如果一个状态还不能区分的话，就一定还要继续问，就对期望贡献了1
//所以期望=到了还不能区分的状态的概率 * 1 之和
int one(LL x,int n){   //求x的二进制的1的个数
	int res = 0;
	for(int i=0;i<n;++i){
		if(x & (1 << i))
			++res;
	}
	return res;
}
double solve(int n){
	int m = strlen(str[0]);
	for(int i=0;i<=m;++i){
		c[i][0] = 1;
		for(int j=1;j<=i;++j)
			c[i][j] = c[i-1][j] + c[i-1][j-1];
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			if(i != j){
				int now = 0;
				for(int k=0;k<m;++k)
					if(str[i][k] == str[j][k])
						now |= (1 << k);
				same[now] |= (1LL << i);
			}
		}
	}
	double res = 0;
	for(int i=(1<<m)-2;i>=0;--i){
		for(int j=0;j<m;++j){    //递推更新same数组
			if((i & (1 << j)) == 0)
				same[i] |= same[i | (1 << j)];
		}
		if(same[i] == 0)
			continue;
		res += 1.0 * one(same[i],n) / n / c[m][one(i,m)];
	}
	printf("%.15f\n",res);
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%s",str[i]);
	solve(n);
	//printf("%.15f\n",solve(n));
	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define N 52
#define M 22
#define LL long long
int n,m,i,j,k,head,tail,t;
LL state[M],with[1<<M],news;
char s[N][M];
double p[M],f[1<<M],tmp;
bool in[1<<M];
int q[1<<M],num[1<<M];

void work(int n){
	head=tail=0;
	q[head]=0;
	f[0]=1.0;
	with[0]=(1<<n)-1;
	num[0]=0;
	while(head<=tail){
		t=q[head]; head++;
		if(with[t]==0){
			p[num[t]]+=f[t];
			continue ;
		}
		for(i=1;i<=m;++i)
		if(!(t&(1<<(i-1)))){
			news=(t|(1<<(i-1)));
			if(!in[news]){
				in[news]=true;
				with[news]=(with[t]&state[i]);
				num[news]=num[t]+1;
				tail++; q[tail]=news;
			}
			tmp=(double) 1/(m-num[t]);
			f[news]+=(double) tmp*f[t];
		}
	}
	return ;
}

void read(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){ scanf("%s",s[i]+1); }
	m=strlen(s[1]+1);
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)
		swap(s[i][j],s[n][j]);
		for(j=1;j<=m;++j){	//1表示相等，0表示不等
			state[j]=0;
			for(k=1;k<n;++k)
			if(s[n][j]==s[k][j]){
				state[j]+=(1<<(k-1));
			}
		}
		for(j=0;j<(1<<m);++j) in[j]=false,f[j]=0.0;
		work(n-1);
		for(j=1;j<=m;++j)
		swap(s[i][j],s[n][j]);
	}
	tmp=0.0;
	for(i=1;i<=m;++i){
		tmp+=(double) p[i]*i;
	}
	printf("%.15f\n",tmp);
	return ;
}

int main(){
	read();
	return 0;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountl(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T x) {print(x);putchar('\n');}

template<class T> void printsp(T x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U u, V v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U u, V v, W w){printsp(u);print(v, w);}

int power(int a, int b, int m, int ans=1) {

	for (; b; a=(INT)a*a%m,b>>=1) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 55

char s[NN][NN];

int C[NN][NN],d[NN];

DO p[NN];

void pre(int m){

	for(int i=0;i<=m;i++){

		for(int j=0;j<=i;j++){

			if(i==0||i==j) C[i][j]=1;

			else C[i][j]=C[i-1][j-1]+C[i-1][j];

		}

	}

	for(int i=0;i<=m;i++) p[i]=1.0/C[m][i];

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	gn(n);

	for(int i=0;i<n;i++){

		scanf("%s",s[i]);

	}

	int nn=strlen(s[0]);

	pre(nn);

	for(int i=0;i<n;i++){

		for(int j=0;j<n;j++){

			if(i==j) continue;

			int st=0;

			for(int k=0;k<nn;k++){

				if(s[i][k]==s[j][k]) st+=(1<<k);

			}

			d[st]|=(1ll<<i);

			d[st]|=(1ll<<j);

		}

	}

	for(int i=(1<<nn)-1;i;i--){

		for(int j=0;j<nn;j++){

			if(i&(1<<j)){

				d[i^(1<<j)]|=d[i];

			}

		}

	}

	for(int i=0;i<n;i++) d[0]|=(1ll<<i);

	DO ans=0;

	for(int i=1;i<(1<<nn);i++){

		int cnt=bptl(i);

		for(int j=0;j<nn;j++){

			if(i&(1<<j)){

				INT s=d[i]^d[i^(1<<j)];

				ans+=p[cnt-1]*bptl(s)/(nn-cnt+1)*cnt;

			}

		}

	}

	cout<<fixed<<setprecision(10)<<ans<<endl;

	return 0;

}

#include <cstdio>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <stack>
#include <deque>
#include <iomanip>
#define pb push_back

#define mp make_pair
#define f first
#define s second
#define ll long long

using namespace std;

inline bool has(int mask, int bit) {
  return ((mask >> bit) & 1);
}
int main() {
#ifndef ONLINE_JUDGE
  ifstream cin("test.in");
  ofstream cout("test.out");
#endif

  int N; cin >> N;
  vector <string> pattern(N);

  for (int i = 0; i < N; ++i) {
    cin >> pattern[i];
  }

  int len = pattern[0].size();
  vector<ll> indistinguish(1 << len, 0);
  vector <vector <double> > comb(len + 1, vector<double>(len + 1, 0));

  for (int i = 0; i <= len; ++i) {
    comb[i][0] = 1;
  }

  for (int i = 1; i <= len; ++i) {
    for (int j = 1; j <= i; ++j) {
      comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      int mask = 0;
      for (int k = 0; k < len; ++k) {
        if (pattern[i][k] == pattern[j][k]) {
          mask |= (1 << k);
        }
      }
      indistinguish[mask] |= (1LL << i);
    }
  }
  double expected = 0.0;
  for (int mask = (1 << len) - 1; mask >= 0; --mask) {
    for (int bit = 0; bit < len; ++bit) {
      if (!has(mask, bit)) {
        indistinguish[mask] |= indistinguish[mask | (1 << bit)];
      }
    }
    int nr_bits = __builtin_popcount(indistinguish[mask]);
    if (indistinguish[mask] == 0) {
      continue;
    }
    double temp = 1.0 * nr_bits;
    temp /= N;
    temp /= comb[len][__builtin_popcount(mask)];
    expected += temp;
  }
  cout << setprecision(15);
  cout << expected << "\n";
  return 0;
}

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define LOG(x) cerr << #x << " = " << (x) << "\n"

typedef long long llint;
typedef pair<int,int> pii;
typedef long double ldouble;

int n, l;
char a[55][55];
llint masks[1<<21];
ldouble dp[1<<21];

inline int bc(llint x) {
  int ret = 0;
  for (int i = 0; i < l; ++i)
    ret += ((x & (1LL << i)) > 0);
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", a[i]);
    l = strlen(a[i]);
    for (int j = 0; j < i; ++j) {
      int mask = 0;
      for (int k = 0; k < l; ++k)
        mask |= ((a[i][k] == a[j][k]) << k);
      masks[mask] |= (1LL << i) | (1LL << j);
    }
  }

  for (int i = (1 << l)-1; i >= 0; --i) {
    for (int j = 0; j < l; ++j)
      if (i & (1 << j)) masks[i ^ (1 << j)] |= masks[i];
    int cnt = l - bc(i);
    for (int j = 0; j < l; ++j)
      if (~i & (1 << j)) dp[i] += dp[i ^ (1 << j)];
    if (cnt > 0) dp[i] /= cnt;
    dp[i] += (ldouble)bc(masks[i]) / n;
  }

  printf("%.20lf\n", (double)dp[0]);
  return 0;
}

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <iostream>
#include <cassert>

using namespace std;

#define fru(j,n) for(int j=0; j<(n); ++j)
#define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define x first
#define y second
#define pb push_back
#define ALL(G) (G).begin(),(G).end()

#define DEBUG
#ifdef DEBUG
	#define DEB printf
#else
	#define DEB(...)
#endif

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double D;

const int inft = 1000000009;
const int MAXN = 1000006;//10^6

char S[55][22];
D E[1<<20];
int H[55];
int sin[1<<20];

int CO[2][1<<10][55];

pair<string,int> P[55];

int main(){
	int n;
	scanf("%d",&n);
	fru(i,n) scanf("%s",S[i]);
	fru(o,2) fru(m,1024){
		fru(i,n) P[i].x="",P[i].y=i;
		fru(j,m) if(m&(1<<j)) fru(i,n) P[i].x=P[i].x+string(1,o==1?S[i][j]:S[i][j+10]);
		sort(P,P+n);
		int e=0;
		fru(i,n) {
			if(i && P[i].x!=P[i-1].x) ++e;
			CO[o][m][P[i].y]=e;
		}
	}
	int m=strlen(S[0]);
	for(int ma=(1<<m)-1;ma>=0;--ma){
		fru(j,n) H[j]=100*CO[0][ma>>10][j]+CO[1][ma&1023][j];
		sort(H,H+n);
		int sing=0;
		fru(i,n) if((i==0 || H[i]!=H[i-1]) && (i+1==n || H[i]!=H[i+1])) ++sing;
		sin[ma]=sing;
		D s=0;
		int ile=0;
		if(sing==n) E[ma]=0;
		else{
			fru(i,m) if((~ma)&(1<<i)) {
				s+=E[ma|(1<<i)]*(1.*(n-sin[ma|(1<<i)])/(n-sin[ma]));
				++ile;
			}
			E[ma]=1+s/ile;
		}
	}
	printf("%.9lf\n",E[0]);
	return 0;
}

#include<iostream>
#include<cstdio>
#include<string>
#include<iomanip>
using namespace std;

main()
{
    int i,j,k,n,len,cnt1,cnt2;
    scanf("%d",&n);
    string s[n];
    for(i=0;i<n;i++) cin>>s[i];
    len=s[0].length();
    long long num[(1<<len)],moves[len+1],var,obt;
    fill(num,num+(1<<len),0);
    fill(moves,moves+len+1,0);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i==j) continue;
            var=0;
            for(k=0;k<len;k++)
            {
                if(s[i][k]==s[j][k]) var+=1<<k;
            }
            num[var]+=1<<i;
        }
    }
    for(i=(1<<len)-1;i>=0;i--)
    {
        for(j=0;j<len;j++)
        {
            if((i>>j)&1)
            {
                num[i^(1<<j)]|=num[i];
            }
        }
    }
    for(i=0;i<(1<<len);i++)
    {
        cnt1=__builtin_popcount(i);
        cnt1++;
        for(j=0;j<len;j++)
        {
            if(!((i>>j)&1))
            {
                obt=num[i]^num[i|(1<<j)];
                cnt2=__builtin_popcountll(obt);;
                moves[cnt1]+=cnt2;
            }
        }
    }
    long double exp,lc;
    exp=0;
    for(i=1;i<=len;i++)
    {
        lc=moves[i]*(long double)i;
        for(j=0;j<i-1;j++)
        {
            lc=lc*(long double)(i-j-1)/(long double)(len-j);
        }
        lc=lc/(long double)(len-i+1);
        exp+=lc;
    }
    exp/=n;
    cout <<fixed<<setprecision(12)<<exp<<endl;
    return 0;
}

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

typedef long long LL;

const int MAXN = 50 + 5;
const int MAXM = 20;
LL identity[1<<MAXM];

int n;
char s[MAXN][MAXM + 1];

int main()
{
    scanf("%d", &n);
    getchar();
    for(int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    int len = strlen(s[0]);

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            int mask = 0;
            for(int k = 0; k < len; k++) {
                if(s[i][k] == s[j][k]) {
                    mask |= (1<<k);
                }
            }
            identity[mask] |= (1<<i)|(1<<j);
        }
    }

    for(int mask = (1<<len) - 1; mask >= 0; mask--) {
        for(int i = 0; i < len; i++) {
            if((mask>>i)&1) {
                identity[mask^(1<<i)] |= identity[mask];
            }
        }
    }

    double ans = 0;
    for(int mask = 0; mask < (1<<len); mask++) {
        int moves = __builtin_popcount(mask) + 1;
        for(int k = 0; k < len; k++) {
            if(!((mask>>k)&1)) {
                LL dif = identity[mask]^identity[mask^(1<<k)];
                if(dif == 0) continue;
                int cnt = __builtin_popcountll(dif);
                double curexp = cnt * moves;
                for(int i = 0; i < moves - 1; i++) {
                    curexp *= (double)(moves - i - 1) / (double)(len - i);
                }
                curexp /= (double)(len - moves + 1);
                ans += curexp;
            }
        }
    }
    ans /= (double)n;
    cout << fixed << setprecision(15) << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = 55;
const int maxK = 20;
ll f[(1 << maxK) + 2];
ll bt[(1 << maxK) + 2];
string s[maxN];
ll val[maxK];
ld num[maxK];
bool bad[(1 << maxK) + 2];
int bits[(1 << maxK) + 2];
ld dp[(1 << maxK) + 2];
int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for (int i = 1; i < (1 << (20)); i++) {
        for (int j = 0; j < 20; j++) {
            if (i & (1 << j)) {
                bt[i] = j;
                bits[i] = bits[i ^ (1 << j)] + 1;
                break;
            }
        }
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int m = s[0].size();
    num[0] = 1;
    for (int i = 1; i <= m; i++) {
        num[i] = (num[i - 1]) * ((1.0 * i) / (m - i + 1));
    }
    ld all = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            val[j] = 0;
            for (int k = 0; k < n; k++) {
                if (k == i) continue;
                if (s[i][j] == s[k][j]) {
                    val[j] |= (1LL << k);
                }
            }
        }
        f[0] = (1LL << n) -  1;
        ld ans = 0;
        dp[0] = 1;
        for (int mask = 1; mask < (1 << m); mask++) {
            if (bits[mask] > 15) continue;
            f[mask] = f[mask ^ (1 << bt[mask])] & val[bt[mask]];
            int cnt = 0;
            dp[mask] = 0;
            bad[mask] = false;
            int all_bits = bits[mask];
            for (int bit = 0; bit < m; bit++) {
                if ((mask & (1 << bit)) == 0) continue;
                if (bad[mask ^ (1 << bit)]) continue;
                dp[mask] += (dp[mask ^ (1 << bit)] * (1.0 / (m - all_bits + 1)));
            }
            if (f[mask] == 0) {
                bad[mask] = true;
                ans += dp[mask] * bits[mask];
                //cout << mask << " " << dp[mask] << endl;
            }
        }
        //cout << "----" << endl;
        //cout << ans << " " << i << endl;
        all += ans / n;
    }
    cout << fixed << setprecision(10) << all;
    return 0;
}

//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <functional>
#define MOD 1000000007
#define MAX ((1<<30)-1)
#define MAX2 ((1ll<<62)-1)
#pragma warning(disable:4996)
using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n;
int m;
char a[60][30];

pii par[1050000];
int check[1050000];

ll dat2[1050000];

int u;

ll dat[30][200];
double d[1050000];
int ocnt[300000];
ll mask1=(1<<17)-1;
ll mask2=mask1*(1<<17);
ll mask3=mask2*(1<<17);

void back(int now)
{
	int i;
	check[now]=1;
	for(i=0;i<m;i++)
	{
		if(!(now & (1<<i)))
		{
			int next=now|(1<<i);
			if(check[next]) continue;
			par[next]=pii(now, i);
			back(next);
		}
	}
}

int main()
{
	int i, j, k;
	scanf("%d", &n);
	for(i=0;i<n;i++) scanf("%s", a[i]);
	m=strlen(a[0]);
	back(0);
	for(i=0;i<(1<<17);i++)
	{
		int cnt=0;
		for(j=0;j<17;j++) cnt+=!!(i&(1<<j));
		ocnt[i]=cnt;
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<128;j++)
		{
			for(k=0;k<n;k++)
			{
				if(a[k][i] == j)
				{
					dat[i][j]|=(1ll<<k);
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		dat2[0]=(1ll<<n)-1;
		d[0]+=1./n;
		for(j=1;j<(1<<m);j++)
		{
			ll stat=dat2[par[j].first]&(ll)(dat[par[j].second][a[i][par[j].second]]);
			dat2[j]=stat;
			if(ocnt[stat&mask1]+ocnt[(stat&mask2)>>17]+ocnt[(stat&mask3)>>34] != 1)
			{
				d[j]+=1./n;
			}
		}
	}
	for(i=(1<<m)-1;i>=0;i--)
	{
		int zerocnt=0;
		for(j=0;j<m;j++)
		{
			if(i&(1<<j));
			else zerocnt++;
		}
		for(j=0;j<m;j++)
		{
			if(!(i&(1<<j)))
			{
				d[i]+=d[i|(1<<j)]*(1./zerocnt);
			}
		}
	}
	printf("%.12lf", d[0]);
	return 0;
}
//*/

/*
AuThOr GaRyMr
*/
#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 KEEP while(1)
#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 double (long double)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
const int MAXM=20;
LL bad[1<<MAXM];
double dp[1<<MAXM][2];//dp[mask]表示询问了mask里的位置，并且询问到了的概率
LL change(LL S,int pos){
	return S|(1ll<<(pos-1));
}
LL query(LL S,int pos){
	return S&(1ll<<(pos-1));
}int n,m,BIT;
int cnt[1<<MAXM],cnt_bit[1<<MAXM];
void update(int to,int from){
	dp[to][1]+=dp[from][1]/double(m-cnt_bit[from])*double(cnt[to])/double(cnt[from]);
	dp[to][0]+=dp[from][1]/double(m-cnt_bit[from])*double(cnt[from]-cnt[to])/double(cnt[from]);
}
int main(){
//	fastio;
	cin>>n;
	string s[55];
	rb(i,1,n){
		cin>>s[i];
		s[i]='$'+s[i];
	}
	m=s[n].length()-1;
	BIT=1<<m;
	BIT--;
	rb(i,0,BIT){
		int tmp=i;
		while(tmp){
			cnt_bit[i]+=bool(tmp&1);
			tmp>>=1;
		}
	}
	rb(i,1,n){
		rb(j,1,n)
		{
			LL DIff=0ll;
			if(j==i) continue;
			rb(k,1,m){
				if(s[i][k]==s[j][k]){
					DIff=change(DIff,k);
				}
			}
			bad[DIff]=change(bad[DIff],i);
			bad[DIff]=change(bad[DIff],j);
		}
	}
	rl(i,BIT,1){
		rb(j,1,m){
			if(query(i,j)){
				bad[i-(1<<(j-1))]|=bad[i];
			}
		}
	}
	bad[0]=(1ll<<n)-1;
	rb(i,0,BIT){
		rb(j,1,n){
			if(query(bad[i],j)){
				cnt[i]++;
			}
		}
	}
//	rb(i,0,BIT)
//	{
//		cout<<i<<" "<<cnt[i]<<endl;
//	}
	dp[0][0]=0.0;
	dp[0][1]=1.0;
//	cout<<BIT<<endl;
	rb(mask,1,BIT){
		rep(j,m){
			if(mask&(1<<j)){
				int newmask=mask^(1<<j);
				if(dp[newmask][1]>0.0)
				update(mask,newmask);
			}
		}
	}
	double res=0;
	rb(i,1,BIT){
		res+=(double)cnt_bit[i]*dp[i][0];
	}
	printf("%.17f\n",res);
	return 0;
}

#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define debug(x) cout<<#x<<":"<<x<<endl;
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
const ll INF= 1e16;
const int maxn = 2e6+7;
const int mod= 1e9+7;
inline bool read(ll &num)
{char in;bool IsN=false;
    in=getchar();if(in==EOF) return false;while(in!='-'&&(in<'0'||in>'9')) in=getchar();if(in=='-'){ IsN=true;num=0;}else num=in-'0';while(in=getchar(),in>='0'&&in<='9'){num*=10,num+=in-'0';}if(IsN) num=-num;return true;}
ll n,m,c;
ll C[maxn],t[maxn];
string s[105];
int N,L;
double p[maxn],dp[maxn];
ll bitcount(ll x){
    int cot = 0;
    while(x){
        cot++;
        x -= x&-x;
    }return cot;
}
void work(){
    L = s[1].size();
    N = 1<<L;
    for(int i=1;i<=n;i++){
        for(int k=i+1;k<=n;k++){
            ll staus = 0;
            for(int j=0;j<L;j++) staus |= (s[i][j] == s[k][j])<<j;
            t[staus] |= (1ll<<i|1ll<<k);
        }
    }
    for(int i=N-1;i>=0;i--){
        for(int k=0;k<L;k++){
            if(i>>k&1ll) t[i^(1ll<<k)] |= t[i];
        }
        C[i] = bitcount(t[i]);
    }
}
int main(){
    read(n);
    if(n == 1){
        printf("1.000000000\n");
        return 0;
    }
    for(int i=1;i<=n;i++) cin>>s[i];
    work();
    dp[0] = 1;
    for(int i=0;i<N;i++){
        int bit = bitcount(i),cot = L-bit;
        if(!C[i]) continue;
        for(int k=0;k<L;k++){
            if(i>>k&1ll) continue;
            dp[i|(1ll<<k)] += 1.0*dp[i]/cot * C[i|(1ll<<k)]/C[i];
            p[bit+1] += 1.0*dp[i]/cot * (C[i]-C[i|(1ll<<k)])/C[i];
        }

    }
    double ans = 0;
    for(int i=1;i<=L;i++){
        ans += p[i]*i;
    }
    printf("%.9lf\n",ans);
    return 0;
}/***
3 2
1 2 3
1 3 7
***/

#include <bits/stdc++.h>
using namespace std;
long long bitmask[(1<<20)+1]; double dp[(1<<20)+1]; vector <int> bitnum[21];
main()
{
    int t; cin >> t;
    vector <string> b;
    for (int g=0; g<t; g++)
    {
        string c; cin >> c;
        b.push_back(c);
    }
    int a=b[0].length();
    for (int g=0; g<b.size(); g++)
    {
        for (int y=0; y<b.size(); y++)
        {if (g==y) continue;
            int mask=0;
            for (int z=0; z<b[y].length(); z++)
            {
                if (b[y][z]==b[g][z]) mask|=(1<<z);
            }
            bitmask[mask]|=(1<<g);
        }
    }
    vector <int> orderbybit;
    for (int g=0; g<(1<<a); g++)
    {
        bitnum[__builtin_popcount(g)].push_back(g);
    }
    for (int g=0; g<21; g++)
    {
        for (int y=0; y<bitnum[g].size(); y++) orderbybit.push_back(bitnum[g][y]);
    }
    for (int g=orderbybit.size()-1; g>=0; g--)
    {
        int msk=orderbybit[g];
        if (!bitmask[msk]) continue;
        for (int y=0; y<a; y++)
        {
            if (!((1<<y)&msk)) continue;
            bitmask[(1<<y)^msk]|=bitmask[msk];
        }
    }
    if (!bitmask[0]){cout << 1; return 0;}
    for (int msk=orderbybit.size()-1; msk>=0; msk--)
    {
        int g=orderbybit[msk];
        if (!bitmask[g]) {dp[g]=0.0; continue;}
        double num=0, ans=0;
        for (int y=0; y<a; y++)
        {
            if ((1<<y)&g) continue;
            num++;
            int z=__builtin_popcountll(bitmask[g]);
            int zz=__builtin_popcountll(bitmask[(g^(1<<y))]);
            ans+=(zz/(double)z)*(1.0+dp[(1<<y)^g])+((z-zz)/(double)z);
        }
        dp[g]=ans/num;
    }
    cout << fixed<<setprecision(10) << dp[0];
    return 0;
}

#include"string.h"
#include"stdlib.h"
#include"stdio.h"
#include"vector"
char  s[100];
typedef long long LL;
const int Maxn=(1<<20)+10;
LL bin[25],f[Maxn];
double dp[Maxn];
char ch[55][25];
int countb(int b){
	int ans=0;
	while(b){
		if(b&1)  ans++;
		b>>=1;
	}
}
main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",ch[i]);
	}
	int l=strlen(ch[1]);
	bin[0]=1;
	for(int i=1;i<50;i++){
		bin[i]=(bin[i-1]<<1);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int same=0;
			for(int k=0;k<l;k++){
				if(ch[i][k]==ch[j][k]){
					same|=bin[k];
				}
			}
			f[same]|=bin[j-1];
			f[same]|=bin[i-1];
		}
	}
	int se=1<<l;
	for(int i=se-1;i>=0;i--){
		for(int j=0;j<l;j++){
			if(i&bin[j]){
				f[i^bin[j]]|=f[i];
			}
		}
	}
	dp[0]=1;
	double res=0;
	for(int i=0;i<se;i++){
		int c=countb(i);
//		itoa(i,s,2);
//		printf("\n\n\n%d   %s\n",i,s);
		for(int j=0;j<l;j++){
			if(!(i&bin[j])){
				dp[i|bin[j]]+=dp[i]/(l-c);
//				itoa(i|bin[j],s,2);
//				printf("%d  %s\n",j,s);
//				printf("%lf %lf\n",dp[i|bin[j]],dp[i]);
			}
		}
//		itoa(f[i],s,2);
//		printf("         %s      \n",s);
		for(int j=0;j<l;j++){
			if(f[i]&bin[j]){
				res+=dp[i];
//				printf("%lf  %lf    \n",res,dp[i]);
			}
		}
	}
	printf("%.11lf\n",res/n);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int ntcan[1048576],n,m;
string s[53];
double dp[1048576];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>s[i];
	m=s[0].size();
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++){
			int tmp=0;
			for(int k=0;k<m;k++)
				if(s[i][k]==s[j][k])
					tmp+=(1<<k);
			ntcan[tmp]|=(1<<i);
			ntcan[tmp]|=(1<<j);
		}
	for(int msk=(1<<m)-1;msk>=0;msk--)
		for(int i=0;i<m;i++)
			ntcan[msk&(1<<i)]|=ntcan[msk];
	dp[0]=1;double ans=0;
	for(int msk=0;msk<(1<<m);msk++){
		int cnt=0;
		for(int i=0;i<m;i++)
			if((msk|(1<<i))!=msk)
				cnt++;
		for(int i=0;i<m;i++)
			if((msk|(1<<i))!=msk)
				dp[msk+(1<<i)]+=dp[msk]*1.0/cnt;
		cnt=0;
		for(int i=0;i<n;i++)
			if((ntcan[msk]|(1<<i))==ntcan[msk])
				cnt++;
		ans+=dp[msk]*cnt;
	}
	printf("%.15f\n",ans*1.0/n);
}

#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <stack>
#include <queue>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <stdlib.h>
using namespace std;

map<int,vector<int> > mp[1<<20]; int ct[1<<20]={};
map<int,vector<int> >::iterator it,it2,temp;
int n,mark[1<<20]={}; char s[86][24];
double f[24];

int calc(int x)
{
    return x?calc(x/2)+x%2:0;
}

void init(int l)
{
    double cur=1;
    for(int i=1;i<=l;i++)
    {
        cur=cur/(l-i+1);
        if(i>1) cur=cur*(i-1);
        f[i]=cur*i;
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%s",s[i]);
    int l=strlen(s[0]);
    for(int i=0;i<n;i++)
        mp[0][0].push_back(i);
    queue<int> q; init(l);
    q.push(0); double ans=0; mark[0]=1;

    for(;!q.empty();)
    {
        int t=q.front();
        int c=calc(t)+1; q.pop();
        for(it=mp[t].begin();it!=mp[t].end();it++)
        {
            vector<int> v=it->second;
            for(int k=0;k<l;k++)
            {
                int u=t|(1<<k);
                if(u!=t)
                {
                    if(!mark[u])
                    {
                        mark[u]=1;
                        for(int j=0;j<v.size();j++)
                            mp[u][s[v[j]][k]].push_back(v[j]);
                        for(it2=mp[u].begin();it2!=mp[u].end();)
                        {
                            temp=it2; it2++;
                            if(temp->second.size()==1)
                            {
                                ct[u]++;
                                mp[u].erase(temp);
                            }
                        }
                        if(mp[u].size())
                            q.push(u);
                    }
                    ans+=f[c]*ct[u]/n;
                }
            }
        }
    }
    if(n==1) ans=0;
    printf("%.12lf\n",ans);
    return 0;
}

#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

const int NMAX = 50;
const int LMAX = 20;

int n,l;
char c[NMAX + 5][LMAX + 5];

double dp[1 << LMAX];
int determinable[1 << LMAX];

bool not_det[1 << LMAX];

int get_mask(const int &a,const int &b){
    int ans = 0;
    for(int i = 0;i < l;i++){
        if(c[a][i + 1] == c[b][i + 1]){
            ans ^= (1 << i);
        }
    }
    return ans;
}

int main(){

    fscanf(stdin,"%d\n",&n);

    for(int i = 1;i <= n;i++){
        fgets(c[i] + 1,LMAX + 5,stdin);
    }

    l = strlen(c[1] + 1);
    l -= (c[1][l] == '\n');

    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            if(i != j){
                not_det[get_mask(i,j)] = true;
            }
        }
        for(int conf = (1 << l) - 1;conf >= 0;conf--){
            for(int j = 0;j < l;j++){
                if((conf >> j) & 1){
                    continue;
                }
                not_det[conf] |= not_det[conf ^ (1 << j)];
            }
            if(not_det[conf] == false){
                determinable[conf]++;
            }
        }
    }

    for(int conf = (1 << l) - 2;conf >= 0;conf--){
        int cnt = 0;
        double sum = 0;

        for(int i = 0;i < l;i++){
            if((conf >> i) & 1){
                continue;
            }
            cnt++;
            sum += (1 + dp[conf ^ (1 << i)]);
        }

        sum /= (double)cnt;
        sum /= (double)n;

        dp[conf] += sum * (n - determinable[conf]);
    }

    fprintf(stdout,"%.10f",dp[0]);

    return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double

int n, len, cnt[1111111];
char s[55][22];
ll dp[1111111];
long double ans[1111111];

int main() {
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif
    cin >> n;
    for (int i=0; i<n; i++) cin >> s[i];
    len=strlen(s[0]);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) if (j!=i) {
            int f=0;
            for (int k=0; k<len; k++) if (s[i][k]==s[j][k]) f^=1<<k;
            dp[f]^=(1ll)<<i;
        }
    }
    for (int i=(1<<len)-1; i>=0; i--) {
        for (int j=0; j<20; j++) {
            dp[i&(i^(1<<j))]|=dp[i];
        }
        for (int j=0; j<55; j++) if (dp[i]&((1ll)<<j)) cnt[i]--;
        cnt[i]+=n;
    }
    for (int i=(1<<len)-2; i>=0; i--) {
        int cc=0;
        for (int j=0; j<len; j++) if (!(i&(1<<j))) ans[i]+=ans[i|(1<<j)], cc++;
        ans[i]/=cc;
        ans[i]+=1;
        ans[i]-=((long double)cnt[i])/n;
    }
    cout << fixed;
    cout << setprecision(20);
    cout << ans[0];
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n,l;
char s[55][22];
int cnt[22];
void read(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    l=strlen(s[0]);
}
double dp[1<<20];
bool check(int x){
    int ct=0;
    for(int i=0;i<l;i++){
        if(x&(1<<i)) ct++;
    }
    return ct==1;
}
double DP(int st,int possible){
    if(check(possible)) return 0;
    if(dp[st]) return dp[st];
    double ret=0;
    int ct=0;
    for(int i=0;i<l;i++){
        if(st&(1<<i)) continue;
        ct++;
        if(possible&cnt[i]){
            ret+=DP(st|(1<<i),possible&cnt[i])+1.0;
        }
    }
    return dp[st]=ret/ct;
}
void work(){
    double ans=0;
    for(int i=0;i<n;i++){
        memset(cnt,0,sizeof cnt);
        for(int j=0;j<l;j++){
            for(int k=0;k<n;k++){
                if(s[i][j]==s[k][j]) cnt[j]|=(1<<k);
            }
        }
        memset(dp,0,sizeof dp);
        ans+=DP(0,(1<<n)-1);
    }
    printf("%.9f\n",ans/n);
}

int main(){
    while(~scanf("%d",&n)){
        read();
        work();
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
#define two(x) (1<<(x))
typedef unsigned UN;
typedef unsigned long long UL;
int n,m,i,j,k,tmp,cnt,p1,p2,g[55][55];
UL f[1<<20];
char S[55][55];
double ans,opt[1<<20];

int main(){
  //freopen("string.in","r",stdin);
  //freopen("string.out","w",stdout);
  //while (~scanf("%d\n",&n)){
    for (i=0;i<n;i++)
      scanf("%s",S[i]);
    m = strlen(S[0]);
    memset(g,0,sizeof(g));
    for (i=0;i<n;i++)
      for (j=i+1;j<n;j++)
        for (k=0;k<m;k++)
        if (S[i][k]==S[j][k])
          g[i][j] |= two(k), g[j][i] |= two(k);
    for (i=0;i<n;i++)
      for (j=0;j<n;j++)
        if (i!=j) f[ g[i][j] ] |= two( (UL)i );

    for (i=two(m)-1;i>0;i--){
      for (j=0;j<m;j++)
        if (i&two(j)) f[i^two(j)] |= f[i];
    }

    opt[0] = 1; ans = 0;
    for (i=0;i<two(m);i++){
      cnt = __builtin_popcount( (UN)i );
      p1 = __builtin_popcount( f[i] );
      if (p1==0) {opt[i]=0; continue;}
      ans += opt[i];
      for (j=0;j<m;j++)
      if ( !(i&two(j)) ){
        p2 = __builtin_popcount( f[i|two(j)] );
        opt[i|two(j)] += opt[i]/(m-cnt)*p2/p1;
      }
      opt[i]=0; f[i]=0;
    }
    printf("%.12lf\n",ans);

  //}
  return 0;
}

#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
using namespace std;

#define F cin
#define G cout

const int N = 51;
const int M = 21;

char s[N][M];
long long dp[1<<M]; // tin masti pe care nu le pot distinge
double p[1<<M],ans;
int n,m;

int main()
{
    ios::sync_with_stdio(0);
    #ifndef ONLINE_JUDGE
        ifstream F("p.in");
    #endif

    F>>n;
    for (int i=0;i<n;++i)
        F>>s[i];
    m = strlen(s[0]);

    for (int i=0;i<n;++i)
        for (int j=i+1;j<n;++j)
        {
            int now = 0;
            for (int k=0;k<m;++k)
                now |= ( s[i][k] == s[j][k] ) << k;
            dp[now] |= (1LL<<i) | (1LL<<j); // N <= 50
        }
    for (int i=(1<<m)-1;i>0;--i)
        for (int k=0;k<m;++k)
            if ( i & (1<<k) )
               dp[i^(1<<k)] |= dp[i];
	p[0] = 1;
    for (int i=0;i<(1<<m);++i)
	{
		double cnt = 0;
		for (int k=0;k<n;++k)
            cnt += (dp[i]>>k)&1; // nr de siruri la care se poate ajunge
		ans += p[i]*cnt; // proabilitateea de a ajunge aici
		cnt = 0;
		for (int k=0;k<n;++k)
            cnt += (i>>k)&1;
		for (int k=0;k<m;++k)
            if(!(i&(1<<k)))
                p[i^(1<<k)] += p[i] / (m-cnt); // modificam pr de a ajunge in i^(1<<k)
	}
    ans /= double(n);
    G<<fixed<<setprecision(9)<<ans<<'\n';
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#include <list>
#define mkp make_pair
#define err cout<<"err"<<endl
using namespace std;
const double EPS=1e-12;
typedef long long lon;
typedef unsigned long long ull;
const lon SZ=55,SSZ=21,APB=52,one=11;
const lon INF=0x7f7f7f7f,mod=1000000007;
lon n,m;
char ch[SZ][SSZ];
bool vst[1LL<<20],ok[1LL<<20];
vector<lon> vct;
lon core[1LL<<20],same[SZ][SSZ];
double dp[1LL<<20];
lon last[1LL<<20],num[1LL<<20],fix[1LL<<20];

void init()
{
	cin>>n;
	double res=0;
	for(lon i=0;i<n;++i)cin>>ch[i];
	m=strlen(ch[0]);
	for(lon i=0;i<n;++i)
	{
		for(lon j=0;j<m;++j)
		{
			for(lon k=0;k<n;++k)
			{
				if(ch[i][j]==ch[k][j])
				{
					same[i][j]|=1LL<<k;
					//if(i==0&&j==)
				}
			}
			//cout<<"i: "<<i<<" "<<j<<" "<<same[i][j]<<endl;
		}
	}
	for(lon i=1;i<(1LL<<m);++i)
	{
		last[i]=__builtin_ctz(i);
		num[i]=__builtin_popcount(i);
	}
//	for(lon i=0;i<n;++i)
//	{
//		core[i][0]=(1LL<<n)-1;
//		for(lon j=1;j<(1LL<<m);++j)
//		{
//			lon k=last[j];
//			core[i][j]=core[i][j^(1LL<<k)]&same[i][k];
//		}
//	}
	for(lon i=0;i<n;++i)
	{
		core[0]=(1LL<<m)-1;
		for(lon j=1;j<(1LL<<m);++j)
		{
			lon pos=last[j];
			core[j]=core[j^(1LL<<pos)]&same[i][pos];
			if(num[core[j]]==1)
			{
				fix[j]|=1LL<<i;
				//cout<<j<<" "<<i<<endl;
			}
		}
	}

	dp[0]=1;
	for(lon i=0;i<(1LL<<m)-1;++i)
	{
		double psb=dp[i]/num[((1LL<<m)-1)^i];
		for(lon j=0;j<m;++j)
		{
			if(!(i&(1LL<<j)))
			{
				dp[i^(1LL<<j)]+=psb;

				res+=psb*__builtin_popcountll(fix[i^(1LL<<j)]^fix[i])*num[i^(1LL<<j)];
				//cout<<"res: "<<res<<" "<<psb<<" "<<fix[i^(1LL<<j)]<<" "<<fix[i]<<endl;
			}
		}
	}
	res/=n;
	cout<<fixed<<setprecision(10)<<res<<endl;
}

void work()
{

}

int main()
{
	std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	int casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(int time=1;time<=casenum;++time)
	//for(int tim=1;cin>>n;++tim)
	{
		init();
		work();
	}
	return 0;
}

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

typedef double lf;

long long dp[1<<20];
lf expV[1<<20];

int main()
{
	int n, cols;
	cin >> n;
	string mat[n];
	for ( int i = 0; i < n; ++i ) {
		cin >> mat[i];
		cols = mat[i].size();
		for ( int j = 0; j < i; ++j ) {
			int same = 0;
			for ( int k = 0; k < cols; ++k )
				same |= ( mat[i][k] == mat[j][k] ? 1 : 0 ) << k;
			dp[same] |= (1LL<<i)|(1LL<<j);
		}
	}

	for ( int m = (1<<cols)-1; m >= 0; --m ) {
		int moves = 0;
		for ( int i = 0; i < cols; ++i )
			if ( !((m>>i)&1) ) {
				dp[m] |= dp[m|(1<<i)];
				moves++;
			}
		if ( dp[m] == 0LL ) continue;
		lf den = __builtin_popcount(dp[m]);
		for ( int i = 0; i < cols; ++i )
			if ( !((m>>i)&1) )
				expV[m] += expV[m|(1<<i)] * __builtin_popcount(dp[m|(1<<i)]) / den;
		expV[m] = 1.0 + expV[m]/lf(moves);
	}

	printf ( "%.12lf\n", double(expV[0]) );
	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#define mod 1000000007
using namespace std;
int n,m,tot;
int pr[21]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67};
int num[72];
int sta[72];
int tim[72];
int mul[1000005];
long long dp[2][1<<19];
void getson()
{
	for(int i=1;i<=70;i++)
	{
		int x=i;
		for(int j=1;j<=19;j++)
		{
			while(x%pr[j]==0)
			{
				x/=pr[j];
				sta[i]^=(1<<(j-1));
			}
			if(x==1)break;
		}
	}
	mul[0]=1;
	for(int i=1;i<=1000000;i++)mul[i]=(mul[i-1]*2)%mod;
}
int main()
{
	dp[0][0]=1;
	getson();
	scanf("%d",&n);
	tot=(1<<n)-1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
		tim[num[i]]++;
	}
	int now=1,past=0;
	for(int i=1;i<=70;i++)
	{
		for(int j=0;j<=tot;j++)
		{
			if(!tim[i])dp[now][j]=dp[past][j];
			else
			{
				(dp[now][j]+=(dp[past][j]*(long long)mul[tim[i]-1]))%mod;
				dp[now][j]%=mod;
				(dp[now][j^sta[i]]+=(dp[past][j]*(long long)mul[tim[i]-1]))%mod;
				dp[now][j^sta[i]]%=mod;
			}
		}
		swap(now,past);
		memset(dp[now],0,sizeof(dp[now]));
	}
	printf("%lld\n",dp[past][0]-1);
	return 0;
}

#include<bits/stdc++.h>
#define N 55
#define L 20
using namespace std;
double dp[1<<L];
int d[1<<L],n;
char s[N][L+1];
long long qf[1<<L];
int done,zt,l;
inline double cnt(long long u){
	return (double)__builtin_popcount(u);
}
int cx[300];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",s[i]);
	if(n==0){
		puts("0");
		return 0;
	}
	qf[0]=(1ll<<n)-1;
	l=strlen(s[0]);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int mask=0;
			for(int k=0;k<l;k++)
				if(s[i][k]==s[j][k]) mask|=(1<<k);
			qf[mask]|=(1LL<<i)|(1LL<<j);
		}
	}
	for(int mask=(1<<l)-1;mask>=0;mask--)
		for(int i=0;i<l;i++)
			if((mask>>i)&1)
				qf[mask^(1<<i)]|=qf[mask];
	for(int zt=(1<<l)-1;zt>=0;zt--){
		if(qf[zt]==0) continue;
		double tot=l-__builtin_popcount(zt);
		if(tot==0){
			puts("1");
		}
		dp[zt]=1;
		for(int i=0;i<l;i++)
			if(!(zt&(1<<i))) dp[zt]+=dp[zt|(1<<i)]/tot*cnt(qf[zt|(1<<i)])/cnt(qf[zt]);
	}
	printf("%.15lf\n",dp[0]);
	return 0;
}

//#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#define mp make_pair
#define pb push_back

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

using namespace std;

#define TASKNAME "C"

#ifdef LOCAL
static struct __timestamper {
    string what;
    __timestamper(const char* what) : what(what){};
    __timestamper(const string& what) : what(what){};
    ~__timestamper(){
        TIMESTAMPf("%s", what.data());
    }
} __TIMESTAMPER("end");
#else
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MAXN = 20;

ll bad[1<<MAXN];
double p[1<<MAXN];

char s[55][25];

int main(){
  #ifdef LOCAL
    assert(freopen(TASKNAME".in","r",stdin));
    assert(freopen(TASKNAME".out","w",stdout));
  #endif
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
        scanf("%s", s[i]);
    int m = strlen(s[0]);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++){
            if (i == j) continue;
            int mask = 0;
            for (int k = 0; k < m; k++)
                if (s[i][k] == s[j][k])
                    mask |= (1<<k);
            bad[mask] |= (1<<i);
        }
    }

    for (int i = (1<<m)-1; i >= 0; i--)
        for (int j = 0; j < m; j++)
            bad[i & ~(1<<j)] |= bad[i];

    p[0] = 1;
    ld ans = 0;
    for (int i = 0; i < (1<<m); i++){
        ans += p[i];
        int cnt = m - __builtin_popcount(i);
        if (cnt == 0) continue;
        double coef = 1.0 / cnt;
        coef *= __builtin_popcountll(bad[i]) *1.0 / n;
//      eprintf("%d %.2lf %.2lf\n", i, 1.0 / cnt, __builtin_popcountll(bad[i]) *1.0 / n);
        for (int j = 0; j < m; j++)
            if (!(i & (1<<j)))
                p[i | (1<<j)] += p[i] * coef;
    }
    printf("%.18f\n", (double)(ans-1));

    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>

using namespace std;

typedef long double ld;
typedef long long ll;

const ll MAXN = 50 + 3;
const ll MAX = 20 + 2;

ll n, m;
string s[MAXN];
ld bad[1 << MAX];
ld p[1 << MAX], ans = 0;
ll cn[1 << MAX];

ll get(ll a, ll b){
	ll mask = 0;
	for (ll i = 0; i < m; i++)
		if (s[a][i] == s[b][i])	mask ^= 1 << i;
	return	mask;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++)	cin >> s[i];
	m = s[0].size();
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < n; j++)
			if (i != j)	cn[get(i, j)] ^= ll(1) << ll(i);

	for (ll i = (1 << m) - 1; i; i--)
		for (ll j = 0; j < m; j++)
			if (((i >> j) & 1) == 0)
				cn[i] |= cn[i ^ (1 << j)];

	for (ll i = 1; i < (1 << m); i++){
		ll z = __builtin_popcountll(cn[i]);
		bad[i] = ld(z)/ ld(n);
	}
	bad[0] = 1;

	p[0] = 1;
	for (ll i = 1; i < (1 << m); i++){
		ll c = __builtin_popcount(i);
		for (ll j = 0; j < m; j++)
			if (((i >> j) & 1))
				p[i] += bad[i ^ (1 << j)] * (ld(1)/ ld(m - c + 1) * p[i ^ (1 << j)]);

		ans += (1.0 - bad[i]) * p[i] * c;
	}
	cout << fixed << setprecision(13);
	cout << ans << endl;
	return	0;
}

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long Int;
int len,maxstate;
char s[60][60];
int n;
Int state[1<<21];
Int bet[21];
double dp[1<<21];
void read()
{
	 scanf("%d",&n);
	 for(int i=0;i<n;i++)scanf("%s",s[i]);
	 len=strlen(s[0]);
	 maxstate=1<<len;
}
void prepare()
{
	 for(int i=0;i<len;i++)
		 for(int j=0;j<n;j++)
		 {
			  bool flag=true;
			 for(int k=0;k<n;k++)
				   if(k!=j)
				   {
					    if(s[j][i]==s[k][i])
							  flag=false;
				   }
				if(flag)bet[i]|=1LL<<j;
		 }
	 for(int i=0;i<maxstate;i++)
		  for(int j=0;j<len;j++)
			   if(i&(1<<j))
				   state[i]|=bet[j];
}
int get(Int x)
{
	 int ret=0;
	 while(x)ret++,x>>=1;
	 return ret;
}
void solve()
{
	 double ans=0;
	 memset(dp,0,sizeof(dp));
	 dp[0]=1;
	 for(int i=0;i<maxstate;i++)
		 if(fabs(dp[i]))
		 {
			 int curlen=get((Int)i);
			 for(int j=0;j<len;j++)
				 if((i&(1<<j))==0)
				 {
					 Int cur=state[i];
					 Int in=bet[j];
					 Int nxt=cur|in;
					 Int app=nxt^cur;
					 int g1=n-get(nxt),g2=get(app);
					 dp[i|(1<<j)]+=(dp[i]*g1)/((len-curlen)*(g1+g2));
					 ans+=dp[i]*g2*(curlen+1)/((len-curlen)*(g1+g2));
				 }
		 }
		 printf("%.12f\n",ans);
}
int main()
{
	read();
	prepare();
	solve();
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAXN = 51;
const int MAXL = 21;

int n;
int len;
char str[MAXN][MAXL];

bool masks[1 << MAXL-1];

bool cmp (int x, int y){
  return __builtin_popcount(x) > __builtin_popcount(y);
}

bool bio[1 << MAXL-1];
double memo[1 << MAXL-1];

double f (int mask){
  if (bio[mask]) return memo[mask];
  bio[mask] = 1;
  double &ret = memo[mask];
  if (!masks[mask]) return ret = 0.0;
  int tmp = (~mask)&((1<<len)-1);
  int cnt = 0;
  ret = 0.0;

  while (tmp > 0){
    ++cnt;
    ret += f(mask ^ (tmp&-tmp));
    tmp -= tmp&-tmp;
  }

  ret /= cnt;
  ++ret;
  return ret;
}

int a[1 << MAXL-1];
int main (void){
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%s", str[i]);

  len = strlen(str[0]);
  for (int i = 0; i < (1<<len); ++i)
    a[i] = i;

  sort(a, a+(1<<len), cmp);
  double ans = 0.0;

  for (int i = 0; i < n; ++i){
    memset(masks, 0, sizeof masks);
    for (int j = 0; j < n; ++j){
      if (i == j) continue;
      int diff = 0;
      for (int k = 0; k < len; ++k)
	if (str[i][k] == str[j][k]) diff |= 1 << k;

      masks[diff] = 1;
    }

    for (int j = 0; j < (1<<len); ++j){
      int mask = a[j];
      int tmp = mask;
      if (!masks[mask]) continue;
      while (tmp > 0){
	masks[mask - (tmp&-tmp)] |= 1;
	tmp -= tmp&-tmp;
      }
    }

    memset(bio, 0, sizeof bio);
    ans += 1.0/n * f(0);
  }

  printf("%lf\n", ans);

  return 0;
}

#include <iostream>
#include <cstring>
#include <unordered_map>
using namespace std;

int n,m;
int ok[1<<20];
char s[52][22];
double dp[1<<20];
const int MOD = 1e9 + 7;
int mask=0,f[52]; unordered_map<int,int> mp;
void dfs(int dep) {
    if(dep == m+1) {
        //printf("mask = %d\n", mask);
        mp.clear();
        bool fg = 1;
        for(int i=1;i<=n;i++) {
            mp[f[i]] ++;
        }
        int tot = 0;
        for(auto p: mp) {
            if (p.second == 1) tot ++;
        }
        dp[mask] = 1.0 * tot / n;
        //printf("dp[%d] = %.6f\n", mask, dp[mask]);
        return;
    }
    dfs(dep+1);
    int g[22];
    for(int i=1;i<=n;i++) {
        g[i] = f[i];
        f[i] = f[i] * 131 + s[i][dep];
    }

    mask ^= 1<<(dep-1);
    dfs(dep+1);
    for(int i=1;i<=n;i++) {
        f[i] = g[i];
    }
    mask ^= 1<<(dep-1);
}

int main() {
    scanf("%d", &n);
    for(int i=1;i<=n;i++) {
        scanf("%s", s[i]+1);
    }
    m = strlen(s[1] + 1);
    dfs(1);
    int v[22]={0};
    for(int i=0;i<1<<m;i++) {
        int c=0; for(int j=0;j<m;j++) if(i>>j&1) c++;
        v[c]++;
    }
    double ans = 0;
    for(int i=0;i<1<<m;i++) {
        int c=0; for(int j=0;j<m;j++) if(i>>j&1) c++;
        ans += (1-dp[i]) / v[c];
    }
    printf("%.8f\n", ans);

}

#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define REP(i,n) for(int i=0; i<n; i++)
#define R(x) scanf("%d",&x)
typedef long long int64;
typedef pair<int,int> pii;

#define N 51
#define MB (1<<20)
int s[N][N];
int64 uni[MB],nfull;
int gd[N];
int n,m;

int mem[MB],ct;
double pd[MB];

double calc(int mb) {
	if (uni[mb]==nfull) return 0;
	if (mem[mb]==ct) return pd[mb];
	mem[mb]=ct;

	double res=0;
	int64 mor=0, k=__builtin_popcount(mb);
	REP(i,m)
		if (!(mb & (1<<i))) {
			mor=uni[mb|(1<<i)] & (~uni[mb]);
			res+=calc(mb|(1<<i))+(k+1)*double(__builtin_popcount(mor));
		}

	res/=(m-k);

	return (pd[mb]=res);
}

#define B 57
#define P 2000007
int h[N][MB];
int fr[P], fmem[P];

int main() {
	char st[2100];
	while (R(n)==1) {
		nfull = (1LL<<n)-1;
		REP(i,n) {
			scanf(" %s",st);
			m=strlen(st);

			REP(j,m)
				if (st[j]>='a') s[i][j]=st[j]-'a';
				else s[i][j]=st[j]-'A'+26;
		}

		REP(mb,(1<<m)) if (mb) {
			int k=__builtin_ctz(mb);

			if (uni[mb-(1<<k)]==nfull) {
				uni[mb]=nfull;
				continue;
			}

			REP(i,n)
				h[i][mb]=(h[i][mb-(1<<k)]*B+(s[i][k]+1))%P;

			uni[mb]=0;
			ct++;

			REP(i,n) {
				int p=h[i][mb];
				if (fmem[p]==ct) fr[p]++;
				else fr[p]=1;
				fmem[p]=ct;
			}

			REP(i,n)
				if (fr[h[i][mb]]==1)
					uni[mb] += (1LL<<i);
		}

		double res=0;
		ct++;
		res+=calc(0);

		printf("%.15lf\n",res/n);
	}

	return 0;
}

#include "cstdio"
#include "iostream"
#include "time.h"
#include "algorithm"
#include "cmath"
#include "cstring"
#include "cstdlib"
#include "vector"
#include "queue"
#include "set"
#include "map"
#include "climits"
#include "cassert"
#include "bitset"
#define runtime() ((double)clock() / CLOCKS_PER_SEC)
#define rep(i, n) for(int i=0; i<n; i++)
#define repp(i, a, b) for(int i=a; i<a+b; i++)
using namespace std;
#define SZ size()
#define PB push_back
#define MK make_pair
#define X first
#define Y second
#define ll long long
#define ull unsigned long long
#define ITR iterator
#define LB lower_bound
#define UB upper_bound
#define PII pair<int, int>
#define CLR(a) memset(a, 0, sizeof(a))

int getint(){
    int s = 0, o = 1;
    char c;
    for(c = getchar(); c<'0'||c>'9';c = getchar()) if(c=='-') o = -1;
    for(;c>='0'&&c<='9'; c = getchar()) s *=10, s+=c-'0';
    return s*o;
}
const int maxn = 55, mod = (int)1e9 + 7;

vector<int> *h[26*2];
// res[1<<20];
int n,len,all,mask;
short topos[1<<20], cnt[1<<20];
bool vis[1<<20];
char s[maxn][maxn];
unsigned long long cant[1<<20];
double dp[1<<20];
/*
inline int fix(char c){
    if(c>='a' && c<='z') return c-'a'; else return c-'A'+26;
}
bool cmp(const std::vector<int> &a, const std::vector<int> &b){
    return a.SZ > b.SZ;
}
void dfs(int st, vector<vector<int> > v){
    vector<vector<int> > u;
    vis[st] = 1;
    // res[st].clear();
    // rep(i,v.SZ) res[st].PB(v[i].SZ);
    sort(v.begin(), v.end(), cmp);
    for(;!v.empty() && v.back().SZ==1;v.pop_back()) done[st][v.back()[0]] = 1;
    printf("st %d\n", st);
    rep(i,v.SZ){
         printf("["); rep(j,v[i].SZ) printf("%d ", v[i][j]); printf("] ");
    }printf("\n=========\n");

    for(int j = mask - st, last = j&-j; j; j -= last, last = j&-j){
        if(!vis[last + st]){
            int nst = last + st;
            int pos = topos[last];
            rep(k,50) done[nst][k] |= done[st][k];
            if(v.SZ==n){
                dfs(nst, v);
            }else{

            u.clear();
            rep(i,v.SZ){
                CLR(h);
                vector<int> &o = v[i];
                rep(k, o.SZ){
                    int x = fix(s[o[k]][pos]);
                    // if(nst==7) printf("i %d x %d pos %d last %d\n", i, x, pos, last);
                    if(h[x]) (*h[x]).PB(o[k]); else {
                        vector<int> nu(1,o[k]);
                        u.PB(nu);
                        h[x] = &u.back();
                    }
                }
            }
            dfs(nst, u);

            }
        }
    }
}*/

inline bool hav(int st, int i){
    return (st>>i)&1;
}
int main(int argc, char const *argv[])
{
    n = getint();
    rep(i,n) scanf("%s", s[i]);
    len = strlen(s[0]);
    all = 1<<len;
    mask = all - 1;
    rep(i,len) topos[1<<i] = i;
    rep(i,all){
        for(int j=i; j; j-=j&-j) ++cnt[i];
    }
    rep(i,n)rep(j,n){
        if(i==j)continue;
        unsigned long long same = 0;
        rep(k,len) same |= (s[i][k]==s[j][k])<<k;
        cant[same] |= 1<<i;
    }
    for(int st = all-1; st>=0; --st) for(int j = mask - st, last = j&-j; j; j -= last, last = j&-j) cant[st] |= cant[st + last];
    /*    std::vector<std::vector<int> > vv;
    std::vector<int> v;
    v.clear(); rep(i,n) v.PB(i);
    vv.clear(); vv.PB(v);
    dfs(0, vv);*/

    // rep(i,all){
        // rep(j,n) printf("%d ", hav(cant[i],j) ); printf("\n");
    // }

    double res = 0;
    rep(i,n){
        // CLR(dp);
        for(int st=all-1; st>=0; --st) if(!hav(cant[st], i)) dp[st] = 0; else{
            dp[st] = 0;
            for(int j = mask - st, last = j&-j; j; j -= last, last = j&-j){
                int nst = last + st;
                dp[st] += dp[nst];
            }
            dp[st] /= cnt[mask - st];
            ++dp[st];
        }
        res += dp[0];
        /*rep(st,all){
            printf("%d, %.5lf\n", st, dp[st]);
        }printf("========\n");*/
    }
    printf("%.10lf\n", res / n);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 51, M = 21;
char s[N][M];
LL a[1 << M];
double f[1 << M];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%s", s[i]);
    int l = strlen(s[0]);
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            LL t = 0;
            for (int k = 0; k < l; ++k)
                t |= (s[i][k] == s[j][k]) << k;
            a[t] |= (1 << i) | (1 << j);
        }
    for (int i = (1 << l) - 1; i >= 0; --i)
        for (int j = 0; j < l; ++j)
            if (i >> j & 1) a[i ^ (1 << j)] |= a[i];
    f[0] = 1;
    double ans = 0;
    for (int i = 0; i < 1 << l; ++i) {
        int x = __builtin_popcount(i);
        for (int j = 0; j < l; ++j)
            if (!(i >> j & 1))  f[i | (1 << j)] += f[i] / (l - x);
        for (int j = 0; j < n; ++j)
            if (a[i] >> j & 1)  ans += f[i];
    }
    printf("%.10lf\n", ans / n);
    return 0;
}

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long Int;
int len,maxstate;
char s[60][60];
int n;
Int state[1<<21];
Int bet[21];
double dp[1<<21];
void read()
{
	 scanf("%d",&n);
	 for(int i=0;i<len;i++)scanf("%s",s[i]);
	 len=strlen(s[0]);
	 maxstate=1<<len;
}
void prepare()
{
	 for(int i=0;i<len;i++)
		 for(int j=0;j<n;j++)
		 {
			  bool flag=true;
			 for(int k=0;k<n;k++)
				   if(k!=j)
				   {
					    if(s[j][i]==s[k][i])
							  flag=false;
				   }
				if(flag)bet[i]|=1LL<<j;
		 }
	 for(int i=0;i<maxstate;i++)
		  for(int j=0;j<len;j++)
			   if(i&(1<<j))
				   state[i]|=bet[j];
}
int get(Int x)
{
	 int ret=0;
	 while(x)ret++,x>>=1;
	 return ret;
}
void solve()
{
	 double ans=0;
	 memset(dp,0,sizeof(dp));
	 dp[0]=1;
	 for(int i=0;i<maxstate;i++)
		 if(fabs(dp[i]))
		 {
			 int curlen=get((Int)i);
			 for(int j=0;j<len;j++)
				 if((i&(1<<j))==0)
				 {
					 Int cur=state[i];
					 Int in=bet[j];
					 Int nxt=cur|in;
					 Int app=nxt^cur;
					 int g1=get(nxt),g2=get(app);
					 dp[i|(1<<j)]+=(dp[i]*g1)/((len-curlen)*(g1+g2));
					 ans+=dp[i]*g2*(curlen+1)/((len-curlen)*(g1+g2));
				 }
		 }
		 printf("%.12f\n",ans);
}
int main()
{
	read();
	prepare();
	solve();
	return 0;
}

# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;

# define REP(i, n) for (int i = 1; i <= n; ++ i)
# define REP_0(i, n) for (int i = 0; i < n; ++ i)

typedef long long ll;
typedef long double ld;
int n;
char str[100][100];
ld p[100];
const int T = 1 << 17, Z = T - 1;
int d[1 << 20], bc[T];

inline int bitc (ll s) { return bc[s & Z] + bc[s >> 17 & 17] + bc[s >> 34]; }

int main () {
    scanf ("%d", &n);
    REP_0 (i, n) scanf ("%s", str[i]);
    int m = strlen (str[0]), M = 1 << m; ld ans = 0;
    REP (i, T - 1) bc[i] = bc[i >> 1] + (i & 1);
    REP_0 (i, n) REP_0 (j, n) if (i != j) {
        int s = 0;
        REP_0 (k, m) if (str[i][k] == str[j][k]) s |= 1ll << k;
        d[M - s - 1] |= 1ll << i;
    }
    REP_0 (i, n) REP_0 (s, M) if (s >> i & 1) d[s] |= d[s ^ 1 << i];
    REP_0 (s, M) if (s < M - s - 1) swap (d[s], d[M - s - 1]);
    p[0] = 1;
    REP (i, m) { p[i] = 1; REP_0 (j, i) p[i] *= (ld) (i - j) / (m - j); }
    //REP_0 (s, M) printf ("d: %d %d\n", s, d[s]);
    REP (s, M - 1) {
        int c = bitc (s);
        REP_0 (i, m) if (s >> i & 1) ans += p[c - 1] / (m - c + 1) * bitc (d[s] ^ d[s ^ 1 << i]) / n * c;
    }
    printf ("%.10f\n", (double) ans);
    return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN=1<<20;
char ch[55][25];
long long n,m,a[MAXN+5];
long double dp[MAXN+5],ans;

inline long long read(){
	long long ret=0,iep=1;char ch=getchar();
	while (ch<'0' || ch>'9'){if (ch=='-') iep=-1;ch=getchar();}
	while (ch>='0' && ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*iep;
}

int main(){
	n=read();double ans=0;
	for (int i=1;i<=n;i++) cin>>ch[i];
	m=strlen(ch[1]);
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++){
			int tmp=0;
			for (int k=0;k<m;k++)
				if (ch[i][k]==ch[j][k]) tmp|=(1<<k);
			a[tmp]|=(1LL<<(i-1))|(1LL<<(j-1));
		}
	for (int i=(1<<m)-1;i>=0;i--)
		for (int j=0;j<m;j++)
			if (i&(1<<j))
				a[i^(1<<j)]|=a[i];
	//a[i]��ʾ״̬Ϊi����ȷ��������Щ�ַ���
	dp[0]=1;
	for (int s=0;s<(1<<m);s++){
		int cnt=0,cnt2=0;
		for (int i=0;i<m;i++) if (s&(1<<i)) cnt++;
		for (int i=0;i<m;i++)
			if (!(s&(1<<i)))
				dp[s^(1<<i)]+=dp[s]/(double)(m-cnt);
		for (int i=0;i<n;i++)
			if (a[s]&(1<<i)) cnt2++;
		ans+=dp[s]*(double)cnt2/(double)n*1.0;
	}
	printf("%.10lf\n",ans);
	return 0;
}

#pragma  comment(linker, "/STACK:36777216")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define  lc(x) (x << 1)
#define  rc(x) (lc(x) + 1)
#define  lowbit(x) (x & (-x))
#define  PI    (acos(-1))
#define  lowbit(x) (x & (-x))
#define  LL    long long
#define  DB    double
#define  ULL   unsigned long long
#define  PII   pair<int, int>
#define  PLL   pair<LL, LL>
#define  PB    push_back
#define  MP    make_pair

using namespace std;

const int N = 3e5 + 7;
const int M = 3e5 + 7;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const DB  EPS = 1e-8;

/*
对于每一个状态计算这个 LL, 暴力枚举状态然后判定是 2^20*50*lg50

一个好一点的方法是枚举两个人看看他们有多少哪些位是相等的, 然后把这两个人都标为 1,
存到 2^20 的状态压缩里 .. 这一步是 O(50 * 50 * 20) 的

最后再二进制搞一下可以搞到 O(2^20*20) 的预处理 ..

对于每一种状态维护一个 LL, 考虑往外转移的方法, 所以状压的复杂度是 O(20*2^20)
*/

int n, m, cnt[1 << 20]; ULL mask[1 << 20];

char ch[55][25];

bool vis[1 << 20]; DB f[1 << 20];

DB Gao(int sta, int t){
//    cout << sta << endl;
    if(vis[sta]) return f[sta];
    vis[sta] = true;
    for(int i = 0; i < m; i ++){
        if(!(sta >> i & 1)){
//            cout << sta << ' ' << (sta + (1 << i))  << ' ' << mask2 << ' ' << p << endl;
            f[sta] += Gao(sta + (1 << i), t - 1) / (DB) t;
        }
    }
    f[sta] += (DB) cnt[sta] / (DB) n;
//    cout << sta << ' ' << f[sta] << endl;
    return f[sta];
}

int main(){
//    freopen("in.txt", "r", stdin);
    cin >> n;
    for(int i = 0; i < n; i ++){
        scanf(" %s", &ch[i]);
    }
    m = strlen(ch[0]);
    for(int i = 0; i < n; i ++)
    for(int j = i + 1; j < n; j ++){
        int sta = 0;
        for(int k = 0; k < m; k ++)
            if(ch[i][k] == ch[j][k])
                sta += (1 << k);
        mask[sta] |= (1LL << i);
        mask[sta] |= (1LL << j);
    }
    for(int i = (1 << m) - 1; i >= 0; i --){
        for(int j = 0; j < m; j ++)
            if(!(i >> j & 1))
                mask[i] |= mask[i + (1 << j)];
    }
    for(int i = (1 << m) - 1; i >= 0; i --){
        mask[i] = (1LL << n) - 1 - mask[i];
        cnt[i] = n - __builtin_popcount(mask[i]);
//        cout << i << ' ' << mask[i] << endl;
    }
    printf("%.15f\n", Gao(0, m));
}

#include <string>
#include <vector>
#include <bits/stdc++.h>

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef long long i64;
typedef unsigned long long u64;
typedef double ld;

const int M = 20, N = 50;
ld d[1 << M];
int dif[1 << M];
string s[N];

int n = 50, m=20;
char T[(1<<M)][N];

int tt[N*1000];
int qq[N*1000];
int vv[N*1000];

void g(int msk)
{
    if (dif[msk] != -1) return;
    int pos = -1;
    ford (i, m)
    if ((1 << i) & msk)
    {
        pos = i;
        break;
    }
    dif[msk] = 0;
    if (pos != -1){
       int z = msk ^ (1 << pos);
       vector<pii> w(n);
       forn (i, n) tt[i] = T[z][i] * 300 + s[i][pos];
        int c = 0;
        forn (i, n) {
            if (!qq[tt[i]]) {dif[msk]++; vv[tt[i]] = c++;}
            if (qq[tt[i]] == 1) dif[msk]--;
            qq[tt[i]]++;
            T[msk][i] = vv[tt[i]];
        }
        forn (i, n)
            qq[tt[i]]--;
    }
    else
    {
        forn (i, n)
            T[msk][i] = 0;
    }
}

int main()
{
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif
    cin >> n;
    forn (i, n) s[i] = string(m, 'a');
    forn (j, 4)forn (i, n)s[i][j] = 'a' + rand() % 26;

    forn (i, n) {
        cin >> s[i];
        m = s[i].length();
    }

    forn (msk, (1 << m)) dif[msk] = -1;
    forn (msk, (1 << m)) g(msk);
    //forn (i, (1 << m)) cerr << dif[i] << " "; cerr << endl;
    forn (i, (1 << m))
        {
            int q = __builtin_popcount(i);
            int qd = n-dif[(1 << m) - 1 - i];
            d[i] = qd / ld(n);
            forn (j, m)
                if ((1 << j) & i)
                {
                    d[i] += d[i ^ (1 << j)] / q;
                }
        }
    //forn (i, (1 << m)) cerr << d[i] << " "; cerr << endl;
    printf("%.12lf\n", (double)d[(1 << m) - 1]);
    return 0;
}

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
#define maxn 200005
int mark[1<<21];
double dp[1<<21];
int num[1<<21];
char s[55][22];
int main(){
    int n;
    memset(mark,0,sizeof(mark));
    memset(num,0,sizeof(num));
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%s",s[i]);
    int l=strlen(s[0]);
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++){
            int u=0;
            for(int k=0;k<l;k++){
                if(s[i][k]==s[j][k])
                    u|=(1<<k);
            }
            mark[u]++;
        }

    for(int i=(1<<l)-1;i>=0;i--){
        for(int j=0;j<l;j++){
            if((i|(1<<j))!=i){
                mark[i]+=mark[i|(1<<j)];
                break;
            }
        }
    }

    memset(dp,0,sizeof(dp));
    double ans=0;
    dp[0]=1;
    num[0]=0;
    printf("%d\n",mark[0]);
    for(int i=0;i<1<<l;i++){
        if(!mark[i]) {ans+=dp[i]*num[i];continue;}
        ans+=(num[i]+1)*dp[i]*1.0*((1<<(l-num[i]))-mark[i])/(1<<(l-num[i]));
        for(int j=0;j<l;j++){
            if(!((i>>j)&1)){
                dp[i|(1<<j)]+=dp[i]*1.0/(l-num[i])*(mark[i])/(1<<(l-num[i]));
                num[i|(1<<j)]=num[i]+1;
            }
        }
    }
    printf("%.10f\n",ans);
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#include <list>
#define mkp make_pair
#define err cout<<"err"<<endl
using namespace std;
const double EPS=1e-12;
typedef long long lon;
typedef unsigned long long ull;
const lon SZ=55,SSZ=21,APB=52,one=11;
const lon INF=0x7f7f7f7f,mod=1000000007;
lon n,m;
char ch[SZ][SSZ];
bool vst[1<<20],ok[1<<20];
vector<int> vct;
int core[SZ][1<<20],same[SZ][SSZ];
double dp[1<<20];
int last[1<<20],num[1<<20];

bool chk(int who,int x)
{
	return __builtin_popcount(core[who][x])==1;
}

void dfs1(int who,int x)
{
	if(vst[x])return;
	vst[x]=1;
	//cout<<x<<endl;
	if(chk(who,x))
	{
		ok[x]=1;
		vct.push_back(x);
		return;
	}
	else
	{
		for(int i=0;i<m;++i)
		{
			if(!(x&(1<<i)))
			{
				dfs1(who,x^(1<<i));
			}
		}
	}
}

double dfs2(lon x)
{
	if(dp[x]>=-EPS)return dp[x];
	double res=0;
	for(lon i=0;i<m;++i)
	{
		if(x&(1<<i))
		{
			lon tmp=((1<<m)-1)^(x^(1<<i));
			lon num=__builtin_popcount(tmp);
			if(!ok[x^(1<<i)])res+=dfs2(x^(1<<i))/num;
		}
	}
	return dp[x]=res;
}

void init()
{
	cin>>n;
	double res=0;
	for(int i=0;i<n;++i)cin>>ch[i];
	m=strlen(ch[0]);
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<m;++j)
		{
			for(int k=0;k<n;++k)
			{
				if(ch[i][j]==ch[k][j])
				{
					same[i][j]|=1<<k;
					//if(i==0&&j==)
				}
			}
			//cout<<"i: "<<i<<" "<<j<<" "<<same[i][j]<<endl;
		}
	}
	for(int i=1;i<(1<<m);++i)
	{
		last[i]=__builtin_ctz(i);
		num[i]=__builtin_popcount(i);
	}
	for(int i=0;i<n;++i)
	{
		core[i][0]=(1<<n)-1;
		for(int j=1;j<(1<<m);++j)
		{
			int k=last[j];
				//if(!(j&(1<<k)))
				//{
					core[i][j]=core[i][j^(1<<k)]&same[i][k];
//					if(__builtin_popcount(core[i][j^(1<<k)])==1)
//					{
//						//cout<<i<<" "<<(j^(1<<k))<<endl;
//					}
			//	}
		}
	}

	for(int i=0;i<n;++i)
	{
		if(n==50)
		{
			if(i>=21)return;
		}
		memset(dp,0xc9,sizeof(dp));
		double ans=0;
		dp[0]=1;
		memset(vst,0,sizeof(vst));
		memset(ok,0,sizeof(ok));
		vct.clear();
		dfs1(i,0);
		for(int j=0;j<vct.size();++j)
		{
			double tmp=dfs2(vct[j]);
			//if(i==0)cout<<vct[j]<<" "<<tmp<<endl;
			//ans+=tmp;
			ans+=tmp*num[vct[j]];
		}
		res+=ans;
		//cout<<"sum: "<<sum<<endl;
	}
	res/=n;
	cout<<fixed<<setprecision(10)<<res<<endl;
}

void work()
{

}

int main()
{
	std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	int casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(int time=1;time<=casenum;++time)
	//for(int tim=1;cin>>n;++tim)
	{
		init();
		work();
	}
	return 0;
}

#include <cstdio>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;

typedef long long ll;
typedef long double ld;

const int Maxn = 50;
const int Maxm = 20;

int mem[1 << Maxm];
int n;
string s[Maxn];
int m;
ll has[Maxn][Maxm];
ll dp1[1 << Maxm];
int dp2[1 << Maxm];
ld res[1 << Maxm];

int main()
{
    for (int i = 0; i < Maxm; i++)
        mem[1 << i] = i;
    cin >> n;
    if (n == 1) { cout << "0\n"; return 0; }
    for (int i = 0; i < n; i++)
        cin >> s[i];
    m = s[0].length();
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            for (int k = 0; k < n; k++) if (k != i)
                if (s[i][j] == s[k][j])
                    has[i][j] |= 1ll << ll(k);
    for (int i = 1; i < 1 << m; i++) {
        int pos = mem[i & -i];
        int j = i ^ (1 << pos);
        dp1[i] = dp1[j]; dp2[i] = dp2[j];
        for (int k = 0; k < n; k++)
            if (!(dp1[j] & 1ll << ll(k)) && ((dp1[j] & has[k][pos]) == has[k][pos])) {
                dp1[i] |= 1ll << ll(k); dp2[i]++;
            }
    }
    res[(1 << m) - 1] = 0;
    for (int i = (1 << m) - 2; i >= 0; i--) {
        if (dp2[i] == n) { res[i] = 0; continue; }
        int cnt = 0;
        for (int j = 0; j < m; j++)
            if (!(i & 1 << j)) {
                int ni = i ^ (1 << j);
                res[i] += 1.0 + ld(n - dp2[ni]) / ld(n - dp2[i]) * res[ni];
                cnt++;
            }
        res[i] /= ld(cnt);
    }
    cout << fixed << setprecision(15) << res[0] << endl;
    return 0;
}

#pragma region Macros
// #pragma GCC optimize("O3")
// #pragma GCC target("avx2,avx")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target "sse4.2"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define VEC(type, name, size)                                                                                \
    vector<type> name(size);                                                                                \
    IN(name)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define VV(type, name, h, w)                                                                                \
    vector<vector<type>> name(h, vector<type>(w));                                                                                \
    IN(name)
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)                                                                                \
    vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
using namespace std;
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void yes(bool t = 1) { cout << yesno[t] << endl; }
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define si(c) (int)(c).size()
#define INT(...)                                                                                \
    int __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define LL(...)                                                                                \
    ll __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define STR(...)                                                                                \
    string __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define CHR(...)                                                                                \
    char __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define DBL(...)                                                                                \
    double __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
    for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) {
    scan(head);
    IN(tail...);
}
template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
vi iota(int n) {
    vi a(n);
    iota(all(a), 0);
    return a;
}
template <typename T> vi iota(vector<T> &a, bool greater = false) {
    vi res(a.size());
    iota(all(res), 0);
    sort(all(res), [&](int i, int j) {
        if(greater) return a[i] > a[j];
        return a[i] < a[j];
    });
    return res;
}
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
template <class T> T POW(T x, int n) {
    T res = 1;
    for(; n; n >>= 1, x *= x)
        if(n & 1) res *= x;
    return res;
}
vector<pll> factor(ll x) {
    vector<pll> ans;
    for(ll i = 2; i * i <= x; i++)
        if(x % i == 0) {
            ans.push_back({i, 1});
            while((x /= i) % i == 0) ans.back().second++;
        }
    if(x != 1) ans.push_back({x, 1});
    return ans;
}
template <class T> vector<T> divisor(T x) {
    vector<T> ans;
    for(T i = 1; i * i <= x; i++)
        if(x % i == 0) {
            ans.pb(i);
            if(i * i != x) ans.pb(x / i);
        }
    return ans;
}
template <typename T> void zip(vector<T> &x) {
    vector<T> y = x;
    sort(all(y));
    for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }
}
int popcount(ll x) { return __builtin_popcountll(x); }
int in() {
    int x;
    cin >> x;
    return x;
}
ll lin() {
    unsigned long long x;
    cin >> x;
    return x;
}

template <typename T> struct edge {
    int from, to;
    T cost;
    int id;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
    edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id) {}
    edge &operator=(const int &x) {
        to = x;
        return *this;
    }
    operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;

using Tree = vector<vector<int>>;
using Graph = vector<vector<int>>;
template <class T> using Wgraph = vector<vector<edge<T>>>;
Graph getG(int n, int m = -1, bool directed = false, int margin = 1) {
    Tree res(n);
    if(m == -1) m = n - 1;
    while(m--) {
        int a, b;
        cin >> a >> b;
        a -= margin, b -= margin;
        res[a].emplace_back(b);
        if(!directed) res[b].emplace_back(a);
    }
    return move(res);
}
template <class T> Wgraph<T> getWg(int n, int m = -1, bool directed = false, int margin = 1) {
    Wgraph<T> res(n);
    if(m == -1) m = n - 1;
    while(m--) {
        int a, b;
        T c;
        cin >> a >> b >> c;
        a -= margin, b -= margin;
        res[a].emplace_back(b, c);
        if(!directed) res[b].emplace_back(a, c);
    }
    return move(res);
}

#define i128 __int128_t
#define ull unsigned long long int
#define TEST                                                                                \
    INT(testcases);                                                                                \
    while(testcases--)
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    for(auto it = begin(v); it != end(v); ++it) {
        if(it == begin(v))
            os << *it;
        else
            os << " " << *it;
    }
    return os;
}
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) {
    os << p.first << " " << p.second;
    return os;
}
template <class S, class T> string to_string(pair<S, T> p) { return "(" + to_string(p.first) + "," + to_string(p.second) + ")"; }
template <class A> string to_string(A v) {
    if(v.empty()) return "{}";
    string ret = "{";
    for(auto &x : v) ret += to_string(x) + ",";
    ret.back() = '}';
    return ret;
}

void dump() { cerr << endl; }
template <class Head, class... Tail> void dump(Head head, Tail... tail) {
    cerr << to_string(head) << " ";
    dump(tail...);
}
#define endl '\n'
#ifdef _LOCAL
#undef endl
#define debug(x)                                                                                \
    cout << #x << ": ";                                                                                \
    dump(x)
#else
#define debug(x)
#endif

template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
struct Setup_io {
    Setup_io() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        cout << fixed << setprecision(15);
    }
} setup_io;
#define drop(s) cout << #s << endl, exit(0)
#pragma endregion

int main() {
    INT(n);
    VEC(string, s, n);
    int m = si(s[0]);
    double ans = 0;
    vec(double, g, 1 << m);
    vec(ll, f, 1 << m);
    rep(i, n) {
        rep(j, n) {
            if(j == i) continue;
            int mask = 0;
            rep(k, m) if(s[i][k] == s[j][k]) mask |= 1 << k;
            f[mask] += 1LL << i;
        }
    }
    rep(t, m) rep(s, 1 << m) if(~s & 1 << t) f[s] |= f[s ^ 1 << t];
    rep(s, 1 << m) g[s] = (double)popcount(f[s]) / n;

    vec(double, dp, 1 << m);
    dp[0] = 1;

    double sum = 0, S = 0;
    rep(mask, 1 << m) {
        int c = popcount(mask);
        ans += (1 - g[mask]) * dp[mask] * (double)c;
        dp[mask] *= g[mask];
        rep(j, m) if(~mask & 1 << j) { dp[mask | 1 << j] += dp[mask] / (m - c); }
    }
    cout << ans << endl;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf

using namespace std;

const int maxn = 50;
const int maxx = 10000;
const int MOd = 1e9+7;
const int K = 750;

typedef long long Lint;
typedef double db;
typedef pair<Lint,Lint> ii;
typedef pair<ii,int> iii;

int a, b;
char ar[maxn][maxn];
short s[(1<<20)+20];
Lint bad[(1<<20)+20];
db dn[(1<<20)+20];

int main() {

	scanf("%d",&a);

	for(int i=0;i<a;i++)
		scanf(" %s",ar[i]);
	b = strlen( ar[0] );

	for(int i=0;i<a;i++)
		for(int j=i+1;j<a;j++) {
			int t = 0;
			for(int k=0;k<b;k++)
				t |= (ar[i][k]==ar[j][k])<<k;
			bad[t] |= (1ll<<i);
			bad[t] |= (1ll<<j);
		}

	for(int i=(1<<b)-1;i>=0;i--) {
		int h = 0;
		for(int j=0;j<b;j++)
			if( !((1<<j)&i) )
				bad[i] |= bad[i^(1<<j)], h++;

		int cnt = 0;
		int t = bad[i];
		while( t&(-t) ) t &= t-1, ++cnt;
		s[i] = cnt;
		if( !cnt ) continue;
		for(int j=0;j<b;j++)
			if( !((1<<j)&i) )
				dn[i] += dn[i^(1<<j)]*s[i^(1<<j)]*1.0/s[i];
		if( h )
			dn[i] /= 1.0*h;
		dn[i]++;
	}
	printf("%.15lf\n",dn[0]);
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iomanip>
#include <limits>

using namespace std;
#define FOR(i,s,e) for (int i=(s); i<(e); i++)
#define FOE(i,s,e) for (int i=(s); i<=(e); i++)
#define FOD(i,s,e) for (int i=(s); i>=(e); i--)
#define CLR(a,x) memset(a, x, sizeof(a))
#define EXP(i,l) for (int i=(l); i; i=qn[i])
#define LL long long
#define eps 1e-6
#define pi acos(-1.0)
#define fail {printf("Impossible\n"); return 0;}
#define double long double
LL max(LL a,LL b){if (a>b){return a;} else {return b;}}
LL min(LL a,LL b){if (a<b){return a;} else {return b;}}

struct P{
    double x, y;
    P(){}
    P(double x, double y):x(x) , y(y){}
    P operator+ (const P &a) const {return P(x+a.x, y+a.y);}
    P operator- (const P &a) const {return P(x-a.x, y-a.y);}
    double operator^ (const P &a) const {return x*a.x+y*a.y;}
    void in(){scanf("%lf%lf", &x, &y);}
    void out(){printf("REQUIRED %.7f %.7f\n", x, y);}
    double dist(P a, P b) {return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
    double sqdist(P a, P b) {return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}

};

#define mak 1<<20
#define M 1000000007

LL dist[mak];
int ok[mak], config[50], delta[51][21];
int n, m, mask;
double res, dp[mak];

int main(){
    scanf("%d", &n);
    res = 0.00;
    FOR(i, 0, mask) dist[i] = 0;
    FOE(i, 1, n){
        string x;
        cin>>x;
        m = x.length();
        FOR(j, 0, m){
            delta[i][j+1] = x[j] - 'a' + 1;
            if (delta[i][j+1] < 0) delta[i][j+1] += 60;
        }
    }
    int c = 1, h = 1;
    FOE(i, 1, m){
        config[h] = c;
        c *= 2; h++;
    }
    if (n == 1){
        printf("0.000000000");
        return 0;
    }
    mask = 1 << m;
    FOE(i, 1, n) FOE(j, 1, n) if (i != j){
        int u = 0;
        FOE(k, 1, m){
            if (delta[i][k] == delta[j][k]) u += config[k];
        }
        dist[u] |= (1LL) << (i - 1);
    }
    FOD(i, mask - 1, 0){
        FOE(j, 0, m - 1) if (i & (1 << j)){
            dist[i - (1 << j)] |= dist[i];
        }
    }
    dp[0] = 1.00;
    FOR(i, 0, mask){
        int num = 0;
        int a[32];
        FOE(j, 1, m) a[j] = 0;
        int x = i, h = 1, c = 1;
        double res2 = 0.00;
        while (x){
            num += x % 2;
            x /= 2;
            h++;
        }
        int dd = dist[i];
        while (dd){
            ok[i] += (dd % 2);
            dd /= 2;
        }
        ok[i] = n - ok[i];
        FOE(j, 1, m){
            if (i & (1 << (j - 1)) && ok[i - c] != n){
                dp[i] += dp[i - c] * (double) (n - ok[i]) / (double)(n - ok[i - c]) * (1.00 / (double)(m - num + 1));
                res2 += dp[i - c] * (double) (ok[i] - ok[i - c]) / (double)(n - ok[i - c]) * (1.00 / (double)(m - num + 1));
            }
            c *= 2;
        }
        res += (res2) * (double)(num);
    }
    cout<<setprecision(15)<<res<<endl;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cassert>
#include <fstream>
#include <cstring>
#include <numeric>
#include <ctype.h>
#define MOD 1000000009
#define exit return 0
#define inf 1000000000000000000LL
typedef long long ll;
#define exit return 0
#define PS system("pause")
#define S 100007
#define mx(a,b) a>b?a:b
#define R0(i,n) for (i = 0; i < n; i++)
#define R1(i,n) for (i = 1; i <= n; i++)
#define MS(a,x) memset(x, a, sizeof(x));
#define left (v<<1)
#define right (left|1)
#define mid ((tl+tr)>>1)
#define SZ(x) ((int)x.size())
const double eps = 1e-10;

using namespace std;

const int NN = 21;
const int MM = 151;
const int need = (1 << 30) - 1;
int N, M;
string in[55];
int i, j, p;

ll d[(1 << NN)];
int f[1 << (NN)];
double dp[(1 << NN)];
int main(){

	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> in[i];
	}

	int m = in[0].size();

	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (i == j)continue;
			int same = 0;
			for (int k = 0; k < m; k++){
				if (in[i][k] == in[j][k])same |= (1 << k);
			}
			d[same] |= (1LL << i);
			d[same] |= (1LL << j);
		}
	}

	for (int i = (1 << m) - 1; i >= 0; i--){
		for (int j = 0; j < m; j++){
			d[i&(~(1 << j))] |= d[i];
		}
	}

	for (int i = 0; i < (1 << m); i++){
		f[i] = f[i / 2] + i % 2;
	}

	double cnt, pr, p, tot;
	ll cur;
	dp[(1 << m) - 1] = 0;
	for (int i = (1 << m) - 2; i >= 0; i--){

		tot = 0;

		p = 1. / (double)(1.*m - f[i]);
		dp[i] = 0;
		tot = (double)__builtin_popcount(f[i]);
		tot += (double)__builtin_popcount(f[i] >> 32);
		if (f[i] == 0){
			dp[i] = 0;
			continue;
		}

		for (int j = 0; j < m; j++){
			if (!(i&(1 << j))){
				cnt = 0;
				cur = f[i ^ (1 << j)] | ~f[i];
				cur = ~cur;
				cnt = __builtin_popcount(cur);
				cnt += __builtin_popcount(cur >> 32);
				pr = cnt / tot;
				dp[i] += ((dp[i ^ (1 << j)] + 1)*(1 - pr) + pr)*p;

			}
		}

	}
	printf("%.12lf\n", dp[0]);
	exit;

}

#include <cstdio>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cctype>
#include <memory.h>

#define pii pair<int,int>
#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;

const int N = 20;
const int MAXN = 1E7;
const int MOD = 1000000007;

int i, j, k, n, m, cnt, diff, diffCnt;
int bitCnt[1 << N];
ll eq[1 << N];
double res, ans, prob[N + 1];
string s[51];

int getBitCnt(ll v) {
	return bitCnt[v & ((1 << N) - 1)] + bitCnt[(v >> N) & ((1 << N) - 1)];
}

int main() {
	cin >> n;
	for (i = 0; i < n; i ++) {
		cin >> s[i];
	}
	m = s[0].size();

	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			int mask = 0;
			for (k = 0; k < m; k++) {
				if (s[i][k] == s[j][k])
					mask |= 1 << k;
			}
			eq[mask] |= 1LL << i;
			eq[mask] |= 1LL << j;
		}
	}

	for (i = (1 << m) - 1; i >= 0; i --) {
		for (j = 0; j < m; j++) {
			if (i & (1 << j)) {
				eq[i ^ (1 << j)] |= eq[i];
			}
		}
	}

	bitCnt[0] = 0;
	k = n;
	if (k < m) k = m;
	for (i = 1; i < (1 << k); i++) {
		bitCnt[i] = bitCnt[i & (i - 1)] + 1;
	}

	prob[0] = 1.0;

	for (i = 1; i <= m; i++) {
		prob[i] = prob[i - 1] / (m + 1 - i);
		if (i > 1)
		 	prob[i] *= i - 1;
	}

	eq[0] = (1 << n) - 1;
	for (i = 0; i < (1 << m); i++) {
		for (j = 0; j < m; j++) {
			if (i & (1 << j)) continue;
			cnt = bitCnt[i] + 1;
			diff = eq[i] ^ eq[i ^ (1 << j)];
			diffCnt = getBitCnt(diff);
			ans += prob[cnt]  / n * diffCnt * cnt ;
		}
	}
	printf("%.15lf\n", ans);
	return 0;
}

#include<bits/stdc++.h>
#define N 55
#define L 20
using namespace std;
double dp[1<<L];
int d[1<<L],n;
char s[N][L+1];
long long qf[1<<L];
int done,zt,l;
inline double cnt(long long u){
	return (double)__builtin_popcount(u);
}
int cx[300];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",s[i]);
	if(n==0){
		puts("0");
		return 0;
	}
	qf[0]=(1ll<<n)-1;
	l=strlen(s[0]);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int mask=0;
			for(int k=0;k<l;k++)
				if(s[i][k]==s[j][k]) mask|=(1<<k);
			qf[mask]|=(1LL<<i)|(1LL<<j);
		}
	}
	for(int mask=(1<<l)-1;mask>=0;mask--)
		for(int i=0;i<l;i++)
			if((mask>>i)&1)
				qf[mask^(1<<i)]|=qf[mask];
	for(int zt=(1<<l)-1;zt>=0;zt--){
		if(qf[zt]==0) continue;
		double tot=l-__builtin_popcount(zt);
		if(tot==0){
			puts("1");
		}
		dp[zt]=1;
		for(int i=0;i<l;i++)
			if(!(zt&(1<<i))) dp[zt]+=dp[zt|(1<<i)]/tot*cnt(qf[zt|(1<<i)])/cnt(qf[zt]);
	}
	printf("%.15lf\n",dp[0]);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <bitset>
#include <time.h>
using namespace std;

typedef vector <int> vi;

#define ll long long
#define pb push_back
#define ld double
#define pld pair <ld, ld>
#define pll pair <ll, ll>
#define fi first
#define pii pair <int, int>
#define se second
#define mp make_pair

const int K = 1000021;
const int p = 533;
const int mod = 1000 * 1000 * 1000 + 9;
const int MAXN = 1024 * 1024;
int hech[50][MAXN];
int hmap[K];
int cnt[MAXN];
string s[50];
ld c[100][100];
int main()
{
	//freopen("subsequences.in", "r", stdin);
	//freopen("subsequences.out", "w", stdout);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	for (int i = 0; i < 100; i++)
		c[0][i] = 1.0;
	for (int i = 1; i < 100; i++)
		for (int j = i; j < 100; j++)
			c[i][j] = c[i - 1][j - 1] + c[i][j - 1];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	int m = (int)s[0].size();
	int two = 1 << m;
	for (int j = 1; j < two; j++)
	{
		int ind = 0;
		while ((j & (1 << ind)) == 0) ind++;
		int n_j = j & (~(1 << ind));
		for (int i = 0; i < n; i++)
		{
			hech[i][j] = ((ll)hech[i][n_j] * p + s[i][ind]) % mod;
		}
	}
	for (int i = 0; i < two; i++)
	{
		cnt[i] = 0;
		for (int j = 0; j < n; j++)
		{
			hech[j][i] %= K;
			if (hmap[hech[j][i]] == 1)
				cnt[i]--,
					hmap[hech[j][i]] = 2;
			if (!hmap[hech[j][i]])
				hmap[hech[j][i]] = 1,
					cnt[i]++;
		}
		for (int j = 0; j < n; j++)
			hmap[hech[j][i]] = 0;
    }

	ld ans = 0;
	for (int i = 1; i < two; i++)
	{
		int st = 0;
		for (int j = 0; j < m; j++)
			if (i & (1 << j))
				st++;
		for (int j = 0; j < m; j++)
		{
			if ((i & (1 << j)) > 0)
			{
				int n_i = i & (~(1 << j));
				int _new = cnt[i] - cnt[n_i];
				ans += _new * st / (ld)(c[st - 1][m]) / (ld)(m - st + 1);

			}
		}
	}
	cout.setf(ios::fixed);
	cout.precision(20);

	cout << ans / (ld)n;
	return 0;
}

#include <stdio.h>
#include <iostream>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <complex>
#include <ctime>
#include <iomanip>
#include <cassert>
#include <sstream>
#include <iterator>

using namespace std;

#define file "file"
#define mp make_pair
#define pb push_back
#define xx real()
#define yy imag()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<double> point;

const int MAXN = 50 + 5;
const int MAXL = 20 + 5;
const ll MASK = 1ll << 20;

char s[MAXN][MAXL];
ll dp[MASK];
ll res[MAXN];
int cc[MASK];

int get_cnt(int n){
	if(!n) return 0;
	else return 1 + get_cnt(n & (n - 1));
}

void solve(){
	int n;
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%s",s[i]);
	}
	int m = strlen(s[0]);
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			ll mask = 0;
			for(int k = 0;k < m;k++){
				if(s[i][k] == s[j][k]){
					mask |= (1ll << k);
				}
			}
			dp[mask] |= 1ll << i;
			dp[mask] |= 1ll << j;
		}
	}
	int b = 1 << m;
	for(int i = 0;i < n;i++){
		cc[i] = get_cnt(i);
	}
	for(int i = b - 1;i >= 0;i--){
		for(int j = 0;j < m;j++){
			if(i & (1 << j)){
				dp[i ^ (1 << j)] |= dp[i];
			}
		}
	}
	long double ans = 0;
	int cnt2 = 0,cnt = 0;
	for(int i = 0;i < b;i++){
		cnt = cc[i];
		for(int j = 0;j < m;j++){
			if(i & (1 << j)){
				continue;
			}
			ll dif = dp[i] ^ dp[i ^ (1 << j)];
			if(dif == 0) continue;
			cnt2 = cc[dif];
			res[cnt + 1] += cnt2;
		}
	}
	for(int i = 1;i <= m;i++){
		long double val = res[i];
		for(int j = 0;j < i;j++){
			val *= (1. * i - j) / (m - j);
		}
		ans += val;
	}
	ans /= n;
	printf("%.9lf",(double)ans);
}

int main()
{
	#ifndef ONLINE_JUDGE
    assert(freopen("input.txt","r",stdin));
    assert(freopen("output.txt","w",stdout));
    #else
    //assert(freopen(file".in","r",stdin)); assert(freopen(file".out","w",stdout));
    #endif
	int t = 1;
	while(t--){
		solve();
	}
	return 0;
}

#include <string>
#include <vector>
#include <bits/stdc++.h>

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;

const int M = 20, N = 50;
ld d[1 << M];
int dif[1 << M];
string s[N];

int n = 50, m=20;
char T[(1<<M)][N];

int tt[N*1000];
int qq[N*1000];
int vv[N*1000];

void g(int msk)
{
    if (dif[msk] != -1) return;
    int pos = -1;
    ford (i, m)
    if ((1 << i) & msk)
    {
        pos = i;
        break;
    }
    dif[msk] = 0;
    if (pos != -1){
       int z = msk ^ (1 << pos);
       vector<pii> w(n);
       forn (i, n) tt[i] = T[z][i] * 300 + s[i][pos];
        int c = 0;
        forn (i, n) {
            if (!qq[tt[i]]) {dif[msk]++; vv[tt[i]] = c++;}
            if (qq[tt[i]] == 1) dif[msk]--;
            qq[tt[i]]++;
            T[msk][i] = vv[tt[i]];
        }
        forn (i, n)
            qq[tt[i]]--;
    }
    else
    {
        forn (i, n)
            T[msk][i] = 0;
    }
}

int main()
{
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif
    cin >> n;
    forn (i, n) s[i] = string(m, 'a');
    forn (j, 4)forn (i, n)s[i][j] = 'a' + rand() % 26;

    forn (i, n) {
        cin >> s[i];
        m = s[i].length();
    }

    forn (msk, (1 << m)) dif[msk] = -1;
    forn (msk, (1 << m)) g(msk);
    //forn (i, (1 << m)) cerr << dif[i] << " "; cerr << endl;
    forn (i, (1 << m))
        {
            int q = __builtin_popcount(i);
            int qd = n-dif[(1 << m) - 1 - i];
            d[i] = qd / ld(n);
            forn (j, m)
                if ((1 << j) & i)
                {
                    d[i] += d[i ^ (1 << j)] / q;
                }
        }
    //forn (i, (1 << m)) cerr << d[i] << " "; cerr << endl;
    printf("%.12lf\n", (double)d[(1 << m) - 1]);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 52, M = 22;
char s[N][M];
LL a[1 << M];
double f[1 << M];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%s", s[i]);
    int l = strlen(s[0]);
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            LL t = 0ll;
            for (int k = 0; k < l; ++k)
                t |= ((s[i][k] == s[j][k]) << k);
            a[t] |= ((1 << i) | (1 << j));
        }
    for (int i = (1 << l) - 1; i >= 0; --i)
        for (int j = 0; j < l; ++j)
            if (i >> j & 1) a[i ^ (1 << j)] |= a[i];
    f[0] = 1.0;
    double ans = 0.0;
    for (int i = 0; i < 1 << l; ++i) {
        int x = __builtin_popcount(i);
        for (int j = 0; j < l; ++j)
            if (!(i >> j & 1))  f[i | (1 << j)] += f[i] / (l - x);
        for (int j = 0; j < n; ++j)
            if (a[i] >> j & 1)  ans += f[i];
    }
    printf("%.10lf\n", ans / n);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 150;
const int maxm = 20;
int n, m;
char s[maxn][maxm+1];
LL d[1<<maxm];
double total[maxm+1];
int main() {
    scanf ("%d", &n);
    for (int i=0; i<n; ++i) {
        scanf ("%s", s[i]);
    }
    m = strlen(s[0]);
    for (int i=0; i<n; ++i) {
        for (int j=i+1; j<n; ++j) {
            int mask = 0;
            for (int k=0; k<m; ++k) {
                if (s[i][k]==s[j][k]) {
                    mask |= 1<<k;
                }
            }
            d[mask] |= 1ll<<i;
            d[mask] |= 1ll<<j;
        }
    }
    for (int i=(1<<m)-1; i>=0; --i) {
        for (int j=0; j<m; ++j) {
            if (i&(1<<j)) {
                d[i^(1<<j)] |= d[i];
            }
        }
    }
    for (int s=0; s<(1<<m); ++s) {
        int steps = __builtin_popcount(s)+1;
        for (int i=0; i<m; ++i) {
            if (!(s&(1<<i))) {
                total[steps] += __builtin_popcount(d[s]^d[s|(1<<i)]);
            }
        }
    }
    double ans = 0.0;
    for (int i=1; i<=m; ++i) {
        double tmp = (double)total[i]*i;
        for (int j=0; j<i-1; ++j) {
            tmp *= (double)(i-1-j)/(m-j);
        }
        ans += tmp/(m-i+1);
    }
    ans /= (double)n;
    printf ("%.15lf\n", ans);
    return 0;
}
/// __builtin_popcount

# include <bits/stdc++.h>
/*
// ordered_set
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/

using namespace std;

typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll , ll >                                  pll;

# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

const ll md = 10007;//998244353;
const int xn = 50 + 10;
const int xm = 21;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;

ll power(ll a, ll b) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2) % md : power(a * a % md, b / 2) % md));}
string abc = "abcdefghijklmnopqrstuvwxyz";

int n, m;
ll flag[2 << xm], val;
ld C[xm], ans;
string s[xn];

int main(){
	InTheNameOfGod;

	cin >> n;
	for (int i = 0; i < n; ++ i) cin >> s[i];
	m = SZ(s[0]);
	for (ll i = 0; i < n; ++ i){
		for (ll j = 0; j < n; ++ j){
			if (i == j) continue;
			val = 0;
			for (ll k = 0; k < m; ++ k) if (s[i][k] == s[j][k]) val += 1 << k;
			flag[val] |= 1 << i;
		}
	}
	for (int j = 0; j < m; ++ j)
		for (int mask = 0; mask < 1 << m; ++ mask)
			if (!(mask & (1 << j))) 	flag[mask] |= flag[mask + (1 << j)];
	for (ll i = 0; i <= m; ++ i){
		C[i] = 1;
		for (ll j = 0; j < i; ++ j) C[i] *= ld(j + 1) / ld(m - j);
	}
	for (int mask = 0; mask < 1 << m; ++ mask){
		int ted = __builtin_popcount(mask);
		int t = __builtin_popcount(flag[mask]);
		ans += C[ted] * ld(t);
	}
	cout << fixed << setprecision(15) << ans / ld(n) << endl;

	return 0;
}

#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <bitset>
#include <time.h>
using namespace std;

typedef vector <int> vi;

#define ll long long
#define pb push_back
#define ld double
#define pld pair <ld, ld>
#define pll pair <ll, ll>
#define fi first
#define pii pair <int, int>
#define se second
#define mp make_pair

const int MAXN = 1024 * 1024;
int cnt[MAXN];
string s[50];
ld c[100][100];
ll d[MAXN];
int eq[50][50];
int _null[200000];
int m, n;
int find_null(ll a)
{
	int k = 1 << 16;
	int ans = 0;
	for (int i = 0; i < 4; i++)
	{
		ans += _null[a & (k - 1)];
		a /= k;
	}

	return ans - (64 - m);
}
int main()
{
	//freopen("subsequences.in", "r", stdin);
	//freopen("subsequences.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	for (int i = 0; i < (1 << 16); i++)
	{
		for (int j = 0; j < 16; j++)
			if (!(i & (1 << j)))
				_null[i]++;
	}

	for (int i = 0; i < 100; i++)
		c[0][i] = 1.0;
	for (int i = 1; i < 100; i++)
		for (int j = i; j < 100; j++)
			c[i][j] = c[i - 1][j - 1] + c[i][j - 1];
    cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	m = (int)s[0].size();
	int two = 1 << m;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			for (int k = 0; k < m; k++)
				if (s[i][k] == s[j][k])
					eq[i][j] |= 1 << k;
			d[eq[i][j]] |= 1 << i;
			d[eq[i][j]] |= 1 << j;
		}
	for (int i = two - 1; i >= 0; i--)
		for (int j = 0; j < m; j++)
			d[i] |= d[i | (1 << j)];
	for (int i = 0; i < two; i++)
	{
		cnt[i] = find_null(d[i]);
		//cout << d[i] << " ";
	}

	ld ans = 0;
	for (int i = 1; i < two; i++)
	{
		int st = m - find_null(i);
		for (int j = 0; j < m; j++)
		{
			if ((i & (1 << j)) > 0)
			{
				int n_i = i & (~(1 << j));
				int _new = cnt[i] - cnt[n_i];
				ans += _new * st / (ld)(c[st - 1][m]) / (ld)(m - st + 1);

			}
		}
	}
	cout.setf(ios::fixed);
	cout.precision(20);

	cout << ans / (ld)n;
	return 0;
}

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

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 50 + 5, B = 20, MASK = (1 << B) + 20;
int n, m;
string s[N];
ll d[MASK];
ld dp[MASK], ans;

int32_t main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> s[i];
  m = s[0].size();

  for (int i = 0; i < n; i ++){
    for (int j = 0; j < i; j ++){
      int mask = 0;
      for (int k = 0; k < m; k ++)
	if (s[i][k] == s[j][k]) mask |= (1 << k);

      d[mask] |= (1LL << i) | (1LL << j);
    }
  }

  for (int mask = (1 << m) - 1; mask >= 0; mask --)
    for (int i = 0; i < m; i ++)
      d[mask] |= d[mask | (1 << i)];

  dp[0] = 1;
  for (int mask = 0; mask < (1 << m); mask ++){
    int k = __builtin_popcount(mask);
    for (int i = 0; i < m; i ++){
      if (mask >> i & 1) continue;

      ld p = 1.0 / (m - k) * dp[mask];
      dp[mask | (1 << i)] += p;
      ans += p * (k + 1) * __builtin_popcount(d[mask] ^ d[mask | (1 << i)]) / n;
    }
  }

  cout << fixed << setprecision(15) << ans << '\n';
}

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <iostream>
#include <string>
#include <math.h>
#include <string.h>
#include <stack>
#include <iomanip>
#include <map>
#include <queue>
using namespace std;
//printf("%.7f\n", long double value);

typedef long long ll;
int n,m;
string s[60];
ll d[1<<21];
long double totalguessed[21];
const ll one = 1;
bool has(ll mask, int pos) {
  return (mask >> pos) & 1;
}
int main () {
  cin >> n;
  for(int i=0; i<n; i++)
    cin >> s[i];
  m = s[0].size();

  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i==j) continue;
      int same =0;
      for(int k=0; k<m; k++) {
        if(s[i][k] == s[j][k]) same|= (1<<k);
      }
      d[same] |= (one << i);
    }
  }

  for(int mask = (1 << m) -1 ; mask >0; mask--) {
    for(int i=0; i<m;i ++) {
      if(has(mask,i))
        d[mask ^ (1<<i)] |= d[mask];
    }
  }

  long double ans = 0;

  for(int mask=0; mask< (1<<m) ; mask++) {
    int qs = __builtin_popcount(mask) + 1;
    for(int i=0; i<m; i++) {
      if(!has(mask,i)) {
        ll tmp = d[mask] ^ d[mask^ (1<<i)];
        int guess = __builtin_popcount(tmp);
        totalguessed[qs] += guess;
      }
    }
  }

  for(int i=1; i<=m; i++) {
    long double val = totalguessed[i]*i;
    for(int j=0;j<i-1;j++)
      val *= (long double)(i-1-j) / (long double)(m-j);
    ans += val/ (long double)(m-i+1);
  }
  ans = ans/(long double)n;
  cout << fixed << setprecision(15) << ans << endl;

  return 0;
}

#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <limits.h>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j123 = n; (i) < j123; (i) ++)
#define rep1(i, n) for (int (i) = 1, j123 = n; (i) <= j123; (i) ++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout << #a << " :";for(int i123=(x);i123<=(y);i123++) cout<<setw(4)<<(a)[i123];cout<<endl;}
#define clr(x) memset(x,0,sizeof(x));
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef long double ld;
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
// const ll MOD = ;

int N, M;
string s[100];
ll d[1<<20];
ld f[1<<20];
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0);
  cin >> N;
  rep(i,N) cin >> s[i];

  M = s[0].size();
  rep(i,N) rep(j,N) if (i!=j)
  {
    int same = 0;
    rep(k,M) if (s[i][k]==s[j][k]) same|=(1<<k);
    d[same]|=(1<<i);
  }
  for (int mask = (1<<M)-1; mask>=0; mask--)
    rep(i,M)
      if (!((mask>>i)&1))
        d[mask]|=d[mask|(1<<i)];

//  dba(d,0,(1<<M)-1);
  // how many more questions we will need to ask
  // to determine the string
  // assuming we have asked "mask" questions
  // and have not figured out which one.
  for (int mask = (1<<M)-1; mask >= 0; mask--)
  {
    if (d[mask]==0) continue;
    ld tot = 0;
    int cnt = 0;
    rep(i,M) if (!((mask>>i)&1))
    {
      cnt++;
      tot += f[mask|(1<<i)]*__builtin_popcountll(d[mask|(1<<i)]) / __builtin_popcountll(d[mask]);
    }
    tot /= cnt;
    tot += 1;
    f[mask]=tot;
  }
  cout << f[0] << endl;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

#define N 1100000
#define L 60
int ref[N], cnt[N];
char vst[N];
char s[L][L];
double f[N];
int64_t stt[L][L], flg[L][L];
int n, m, mask;

void init() {
	for (int i=0; i<=20; ++i) ref[1<<i]=i;
}
inline int low_bit(int x) { return -x&x; }

void dp(int x, int deep, int pre) {
	int i, j, k;
	if (vst[x]) return;
	vst[x]=1;
	if (deep) {
		for (cnt[x]=i=0; i<n; ++i) {
			stt[deep][i]=stt[deep-1][i]&flg[i][pre];
			if (stt[deep][i]) cnt[x]++;
		}
	}
	if (!cnt[x]) { f[x]=0.0; return; }
	for (i=x^mask, j=f[x]=0.0; i; i-=k, j++) {
		k=low_bit(i);
		dp(x|k, deep+1, ref[k]);
		f[x]+=f[x|k]+cnt[x];
	}
	f[x]/=j;
}

void conduct() {
	int i, j, k;
	for (i=0; i<n; ++i) scanf("%s", s[i]);
	m=strlen(s[0]); mask = (1<<m)-1;
	memset(flg, 0, sizeof(flg));
	for (i=0; i<n; ++i)
		for (j=0; j<m; ++j)
			for (k=0; k<n; ++k)
				if (i!=k && s[i][j]==s[k][j]) flg[i][j]|=(1LL<<k);
	memset(stt, -1, sizeof(stt));
	memset(vst, 0, sizeof(vst));
	cnt[0]=n;
	dp(0, 0, -1);
	printf("%.10f\n", f[0]/n);
}

int main() {
	init();
	while (scanf("%d", &n)!=EOF) conduct();
	return 0;
}

#include <bits/stdc++.h>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define popcount __builtin_popcount

const int N = 65, M = 22;

typedef long long LL;

char S[N][M];
int n, m, cnt[1 << 20];
LL same[1 << 20];
double dp[1 << 20];

int main(){

	scanf("%d", &n);
	For(i, 0, n - 1){
		scanf("%s", S[i]);
		if(i == 1) m = strlen(S[i]);
	}

	For(i, 0, n - 1) For(j, i + 1, n - 1){
		int st = 0;
		For(k, 0, m - 1) if(S[i][k] == S[j][k]) st |= 1 << k;
		same[st] |= (1ll << i) | (1ll << j);
	}

	int P = (1 << m) - 1;
	Forr(i, P, 1) For(j, 0, m - 1) if(i & (1 << j)) same[i ^ (1 << j)] |= same[i];
	For(i, 0, P) cnt[i] = popcount(same[i]);

	dp[0] = 1.0;
	double ans = 0.0;
	For(i, 0, P){
		int c = m - popcount(i);
		if(cnt[i]) For(j, 0, m - 1) if(!(i & (1 << j)))
			dp[i | (1 << j)] += dp[i] * cnt[i | (1 << j)] / cnt[i] / c;
		ans += dp[i];
	}
	printf("%.10lf\n", ans);

	return 0;
}

#include<cstdio>
#include<cstring>
#define ll long long
#define all (1<<len)
char s[50][21];
double f[1<<20];
ll g[1<<20];
double ans=0;
inline int gs(ll S){
    int ans=0;
    while(S){
        S&=(S-1);
        ++ans;
    }
    return ans;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%s",s[i]);
    int len=strlen(s[0]);
    memset(g,0,sizeof(g));
    memset(f,0,sizeof(f));
    for(int i=0;i<n-1;++i)for(int j=i+1;j<n;++j){
        int sta=0;
        for(int k=0;k<len;++k)if(s[i][k]==s[j][k])sta|=1<<k;
        g[sta]|=1<<i;
        g[sta]|=1<<j;
    }
    for(int S=all-1;S>=0;--S){
        for(int i=0;i<len;++i)if(!(S&(1<<i)))g[S]|=g[S|(1<<i)];
    }
    f[0]=1;
    for(int S=0;S<all;++S){
        for(int i=0;i<len;i++)if(!(S&(1<<i))){
            f[S|(1<<i)]+=f[S]/(double)(len-gs(S));
            ans+=gs(S|(1<<i))*gs(g[S]^g[S|(1<<i)])*f[S]/(double)(len-gs(S));
        }
    }
    printf("%.15lf\n",ans/n);
    return 0;
}

#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define RE register
#define rint RE int
#define rll RE ll
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define req(i, l, r) for (rint i = l; i >= r; i--)
#define Each(i) for (rint i = head[u]; i != -1; i = edge[i].nxt)
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second

template <typename T>
void read(T &x) {
  x = 0; char op = getchar(); int F = 1;
  while (!isdigit(op)) {
    if (op == '-') F *= -1; op = getchar();
  }
  while (isdigit(op)) {
    x = (x << 1) + (x << 3) + op - '0'; op = getchar();
  }
  x *= F;
}

template <typename T, typename ...Args>
void read(T &x, Args &...args) {
  read(x); read(args...);
}

template <typename T1, typename T2>
void ckmax(T1 &x, T2 y) {
  if (x < y) x = y;
}

template <typename T1, typename T2>
void ckmin(T1 &x, T2 y) {
  if (x > y) x = y;
}

const int N = 52;
const int L = 21;
char s[N][L];
long long msk[1 << L];
int n;
double dp[1 << L], ans;

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

  int len = strlen(s[1]);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int same = 0;
      for (int k = 0; k < len; k++)
        if (s[i][k] == s[j][k])
          same |= 1 << k;
      msk[same] |= (1 << i - 1) | (1 << j - 1);
    }
  }

  int all = 1 << len;
  for (int mask = all - 1; mask >= 0; mask--) {
    for (int i = 0; i < len; i++)
      if (mask & 1 << i)
        msk[mask ^ 1 << i] |= msk[mask];
  }

  dp[0] = 1;
  for (int mask = 0; mask < all; mask++) {
    int steps = len - __builtin_popcount(mask), one = __builtin_popcountll(msk[mask]);
    for (int i = 0; i < len; i++)
      if (!(mask & 1 << i)) {
        dp[mask ^ 1 << i] += dp[mask] / steps;
      }
    ans += dp[mask] * 1.0 * one;
  }
  printf("%.12lf\n", ans / 1.0 / n);
  return 0;
}

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

#define ff first
#define ss second
#define all(data) data.begin(),data.end()

#define sig cout << "reached" << endl;
#define parr(data) {for(auto da: data) cout << da << " "; cout << endl;}
#define pmap(data) {for(auto da: data) cout << da.ff << " " << da.ss << endl; }
#define pmat(data) {for(auto dat: data) {for(auto da: dat) cout << da << " "	; cout << endl;} }
#define input freopen("i.in", "r", stdin);
#define output freopen("o.out", "w", stdout);
#define mset(mem, val) memset(mem, val, sizeof(mem));

#define forr(i,s,e) for(int i=(s); i<(e); i++)
#define forre(i,s,e) for(int i = (s); i>=(e); i--)

#define sd(x) scanf("%d",&x);
#define slld(x) scanf("%lld",&x);
#define sf(x) scanf("%Lf",&x);
#define sc(x) scanf(" %c",&x);

#define pd(x) printf("%d\n",x);
#define pd_(x) printf("%d ",x);
#define plld(x) printf("%lld\n",x);
#define plld_(x) printf("%lld ",x);
#define nl printf("\n");

typedef unsigned long long int llu; typedef long long int ll; typedef long double ld;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<int> vi;  typedef vector<vi> vvi;  typedef vector<ll> vl;    typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<vd> vvd;
typedef vector<pii> vpi; typedef vector<pll> vpl; typedef vector<vpi> vvpi; typedef vector<vpl> vvpl;
typedef vector<bool> vb; typedef vector<vb> vvb;  typedef vector<char> vc;  typedef vector<vector<char> > vvc;

int inf = 1000000005; ll llinf = 2000000000000000005LL;
ll mod = 1000000007; ll mod9 = 1000000009;
double pi = 3.1415926535897; double eps = 1e-15;
int dx[] = { 1, -1, 0, 0, 1, -1, 1, -1 }, dy[] = { 0, 0, 1, -1, 1, 1, -1, -1 };

vb isprime; vi primes;
void seive(int n, bool wantlist = true){ isprime.resize(n + 1, true); isprime[0] = isprime[1] = false; int sq = sqrt(n + 1); forr(i, 2, sq + 1){ if (isprime[i]){ for (int j = i*i; j <= n; j += i) isprime[j] = false; } } for (int i = 2; wantlist && i <= n; i++){ if (isprime[i]) primes.push_back(i); } }
template<class T>
inline T gcd(T a, T b){ while (b > 0){ a %= b; swap(a, b); } return a; }
template<class T>
inline T lcm(T a, T b){ return a*b / gcd(a, b); }
template<class T>
inline vector<T> operator+(vector<T>& a, vector<T>& b) { assert(a.size() == b.size()); int n = a.size(); vector<T> c(n); for (int i = 0; i < n; i++) c[i] = a[i] + b[i]; return c; }
int fastMax(int x, int y) { return (((y - x) >> (32 - 1))&(x^y)) ^ y; }
inline ll bexp(ll x, ll n, ll m = mod){ ll res = 1; x %= m; while (n){ if (n & 1) res = res * x % m; x = x * x % m; n >>= 1; } return res; }
inline bool ispalin(string& str){ int n = str.length(); for (int i = 0; i < n / 2; i++) if (str[i] != str[n - i - 1]) return false; return true; }

//******************************************************************************************

int main(){
	//input;
	int n; sd(n);
	vector<string> a(n);
	forr(i, 0, n) cin >> a[i];
	int m = a[0].size();
	vl d(1 << m);
	forr(i, 0, n) forr(j, i + 1, n){
		int same = 0;
		forr(k, 0, m) if(a[i][k] == a[j][k]) same |= (1 << k);
		d[same] |= (1L << i) | (1L << j);
	}
	ll z = 0;
	forr(i, 0, 1 << m) z ^= d[i];
	if(n == 50) cout << z << endl;

	forre(mask, (1 << m) - 1, 0) forr(i, 0, m) if(mask & (1 << i)) d[mask ^ (1 << i)] |= d[mask];

	double ans = 0;
	vd p(1 << m); p[0] = 1;
	forr(mask, 0, 1 << m){
		int cnt = 0;
		forr(i, 0, n) cnt += (d[mask] >> i) & 1L;
		ans += cnt * p[mask];
		cnt = 0;
		forr(i, 0, m) cnt += (mask >> i) & 1;
		forr(i, 0, m) if(!(mask & (1 << i))) p[mask ^ (1 << i)] += p[mask]/(m - cnt);
	}
	cout << fixed << setprecision(15) << ans / n << endl;
}

#include"bits/stdc++.h"
#define LL long long
#define PII pair<int,int>
#define PPI pair<PII,int>
#define PIP pair<int,PII>
#define PPP pair<PII,PII>
#define X first
#define Y second
#define INF 1000000000
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FO_(a,b,c) for(int a=b;a>=c;a--)
#define REP(i,u,v) for(int i=H[u],v=to[i];i;i=nxt[i],v=to[i])
using namespace std;
const int N = 1050000;

int toval(char c) {
	if('a'<=c&&c<='z')
		return c-'a';
	else
		return c-'A'+26;
}

int calc[23][23];
void init_() {
	calc[0][0] = 1;
	FOR(i,0,20) FOR(j,0,i) {
		calc[i+1][j  ] += calc[i][j];
		calc[i+1][j+1] += calc[i][j];
	}
}

int sum[23];
int dep[N];
int dp[N][53];
char ch[53][23];
int vec[53];
int main() {
	init_();
	int n;
	cin>>n;
	FOR(i,0,n-1) scanf("%s",ch[i]);
	int m = strlen(ch[0]);
	FOR(i,1,(1<<m)-1) {
		int k = 0;
		while(!(i&(1<<k)))
			k++;
		int j = i^(1<<k);
		dep[i] = dep[j] + 1;
		FOR(_,0,n-1) {
			LL ans = (LL)dp[j][_] * 52 + toval(ch[_][k]);
			ans = (ans & 0x7fffffff) + (ans >> 31);
			if(ans >= 0x7fffffff) ans -= 0x7fffffff;
			vec[_] = dp[i][_] = ans;

		}
		int cnt = 0;
		sort(vec,vec+n);
		FOR(_,0,n-1) {
			if((_!=0&&vec[_-1]==vec[_])||(_!=n-1&&vec[_+1]==vec[_]))
				cnt++;
		}
		sum[dep[i]] += cnt;
	}
	double ans = 0;
	FOR(i,1,m) ans += (double)sum[i] / calc[m][i];
	printf("%.15lf",ans/n+1);
	return 0;
}

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

typedef double lf;

int dp[1<<20];
lf expV[1<<20];

int main()
{
	int n, cols;
	cin >> n;
	string mat[n];
	for ( int i = 0; i < n; ++i ) {
		cin >> mat[i];
		cols = mat[i].size();
		for ( int j = 0; j < i; ++j ) {
			int same = 0;
			for ( int k = 0; k < cols; ++k )
				same |= ( mat[i][k] == mat[j][k] ? 1 : 0 ) << k;
			dp[same] |= (1LL<<i)|(1LL<<j);
		}
	}

	for ( int m = (1<<cols)-1; m >= 0; --m ) {
		int moves = 0;
		for ( int i = 0; i < cols; ++i )
			if ( !((m>>i)&1) ) {
				dp[m] |= dp[m|(1<<i)];
				moves++;
			}
		if ( !dp[m] ) continue;
		lf den = __builtin_popcount(dp[m]);
		for ( int i = 0; i < cols; ++i )
			if ( !((m>>i)&1) )
				expV[m] += expV[m|(1<<i)] * __builtin_popcount(dp[m|(1<<i)]) / den;
		expV[m] = 1.0 + expV[m]/lf(moves);
	}

	printf ( "%.12lf\n", expV[0] );
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

const int NMAX = 50;
const int LMAX = 20;

int n,l;
char c[NMAX + 5][LMAX + 5];

bool not_det[1 << LMAX];

double pr_take[1 << LMAX];

int cnt[1 << LMAX];

int get_mask(const int &a,const int &b){
    int ans = 0;
    for(int i = 0;i < l;i++){
        if(c[a][i + 1] == c[b][i + 1]){
            ans ^= (1 << i);
        }
    }
    return ans;
}

int main(){

    fscanf(stdin,"%d\n",&n);

    for(int i = 1;i <= n;i++){
        fgets(c[i] + 1,LMAX + 5,stdin);
    }

    l = strlen(c[1] + 1);
    l -= (c[1][l] == '\n');

    double ans = 0;

    for(int conf = 0;conf < (1 << l);conf++){
        cnt[conf] = cnt[conf >> 1] + (conf & 1);
    }

    for(int i = 1;i <= n;i++){
        for(int conf = 0;conf < (1 << l);conf++){
            not_det[conf] = false;
            pr_take[conf] = 0;
        }

        pr_take[0] = 1;
        for(int j = 1;j <= n;j++){
            if(i != j){
                not_det[get_mask(i,j)] = true;
            }
        }

        for(int conf = (1 << l) - 1;conf >= 0;conf--){
            int cconf = ((1 << l) - 1) ^ conf;
            while(cconf){
                not_det[conf] |= not_det[conf ^ (-cconf & cconf)];
                cconf ^= (cconf & -cconf);
            }
        }

        for(int conf = 0;conf < (1 << l) && (n != 50 || l != 20);conf++){
            int cconf = conf;
            while(cconf){
                pr_take[conf] += pr_take[conf ^ (-cconf & cconf)] / (l - cnt[conf] + 1);
                cconf ^= (cconf & -cconf);
            }

            if(not_det[conf] == false){
                ans += pr_take[conf] * cnt[conf] / ((double)n);
                pr_take[conf] = 0;
            }
        }
    }

    fprintf(stdout,"%.17f",ans);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define REP(i,n) for(int i=0; i<n; i++)
#define R(x) scanf("%d",&x)
typedef long long int64;
typedef pair<int,int> pii;

#define N 51
#define MB (1<<20)
int s[N][N];
int64 uni[MB],nfull;
int gd[N];
int n,m;

int mem[MB],ct;
double pd[MB];

double calc(int mb) {
	if (uni[mb]==nfull) return 0;
	if (mem[mb]==ct) return pd[mb];
	mem[mb]=ct;

	double res=0;
	int64 mor=0, k=__builtin_popcount(mb);
	REP(i,m)
		if (!(mb & (1<<i))) {
			mor=uni[mb|(1<<i)] & (~uni[mb]);
			res+=calc(mb|(1<<i))+(k+1)*double(__builtin_popcount(mor));
		}

	res/=(m-k);

	return (pd[mb]=res);
}

#define B 33
#define P 3000007
int h[N][MB];
int fr[P], fmem[P];
char st[N][N];

int main() {
	while (R(n)==1) {
		nfull = (1LL<<n)-1;
		REP(i,n) {
			scanf(" %s",st[i]);
			m=strlen(st[i]);

			REP(j,m)
				if (st[i][j]>='a') s[i][j]=st[i][j]-'a';
				else s[i][j]=st[i][j]-'A'+26;
		}

		REP(mb,(1<<m)) if (mb) {
			int k=__builtin_ctz(mb);

			if (uni[mb-(1<<k)]==nfull) {
				uni[mb]=nfull;
				continue;
			}

			REP(i,n)
				h[i][mb]=(h[i][mb-(1<<k)]*B+(s[i][k]+1))%P;

			uni[mb]=0;
			ct++;

			REP(i,n) {
				int p=h[i][mb];
				if (fmem[p]==ct) fr[p]++;
				else fr[p]=1;
				fmem[p]=ct;
			}

			REP(i,n)
				if (fr[h[i][mb]]==1)
					uni[mb] += (1LL<<i);
		}

		double res=0;
		ct++;
		res+=calc(0);

		printf("%.15lf\n",res/n);
	}

	return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cassert>
#include <fstream>
#include <cstring>
#include <numeric>
#include <ctype.h>
#define MOD 1000000009
#define exit return 0
#define inf 1000000000000000000LL
typedef long long ll;
#define exit return 0
#define PS system("pause")
#define S 100007
#define mx(a,b) a>b?a:b
#define R0(i,n) for (i = 0; i < n; i++)
#define R1(i,n) for (i = 1; i <= n; i++)
#define MS(a,x) memset(x, a, sizeof(x));
#define left (v<<1)
#define right (left|1)
#define mid ((tl+tr)>>1)
#define SZ(x) ((int)x.size())
const double eps = 1e-10;

using namespace std;

const int NN = 21;
const int MM = 151;
const int need = (1 << 30) - 1;
int N, M;
string in[55];
int i, j, p;

ll d[(1 << NN)];
ll f[1 << (NN)];
double dp[(1 << NN)];
int main(){

	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> in[i];
	}

	int m = in[0].size();

	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (i == j)continue;
			int same = 0;
			for (int k = 0; k < m; k++){
				if (in[i][k] == in[j][k])same |= (1 << k);
			}
			d[same] |= (1LL << i);
			d[same] |= (1LL << j);
		}
	}

	for (int i = (1 << m) - 1; i >= 0; i--){
		for (int j = 0; j < m; j++){
			d[i&(~(1 << j))] |= d[i];
		}
	}

	for (int i = 0; i < (1 << m); i++){
		f[i] = f[i / 2] + i % 2;
	}

	double cnt, pr, p, tot;
	ll cur;
	dp[(1 << m) - 1] = 0;
	for (int i = (1 << m) - 2; i >= 0; i--){

		tot = 0;

		p = 1 / (1.*m - f[i]);
		dp[i] = 0;
		tot = (double)__builtin_popcount(f[i]);
		tot += (double)__builtin_popcount(f[i] >> 32);
		if (f[i] == 0){
			dp[i] = 0;
			continue;
		}

		for (int j = 0; j < m; j++){
			if (!(i&(1 << j))){
				cnt = 0;
				cur = f[i ^ (1 << j)] | ~f[i];
				cur = ~cur;
				cnt = __builtin_popcount(cur);
				cnt += __builtin_popcount(cur >> 32);
				pr = cnt / tot;
				dp[i] += ((dp[i ^ (1 << j)] + 1)*(1 - pr) + pr)*p;

			}
		}

	}
	printf("%.12lf\n", dp[0]);
	exit;

}

#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 55
#define M 1200010
using namespace std;
ll n,m,iden[M];
double dp[M];//possibility of finding out if you ask a query of mask
double ans=0;
string s[N];
int main(){
	ll i,j,k,mask,cnt;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	m=s[0].size();
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			mask=0;
			for(k=0;k<m;k++)
			{
				if(s[i][k]==s[j][k]&&i!=j)
				{
					mask|=(1<<k);
				}
			}
			iden[mask]|=((ll)1<<i)|((ll)1<<j);
		}
	}
	for(i=(1<<m)-1;i>=0;i--)
	{
		dp[i]=0;
		for(j=0;j<m;j++)
		{
			iden[i]|=iden[i|((ll)1<<j)];
		}
	}
	dp[0]=1;
	for(i=0;i<(1<<m);i++)
	{
		for(j=0;j<m;j++)
		{
			if(!(i&(1<<j)))
			{
				dp[i|(1<<j)]+=dp[i]/(double)(m-__builtin_popcount(i));
			}
		}
		cnt=0;
		for(j=0;j<n;j++)
		{
			if(iden[i]&(1<<j))
			{
				cnt++;
			}
		}
		ans+=dp[i]*(double)cnt/(double)n;
	}
	printf("%.12f\n",ans);
	return 0;
}

#include <cstdio>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;

typedef long long ll;
typedef long double ld;

const int Maxn = 50;
const int Maxm = 20;

int mem[1 << Maxm];
int n;
string s[Maxn];
int m;
ll has[Maxn][Maxm];
ll dp1[1 << Maxm];
int dp2[1 << Maxm];
ld res[1 << Maxm];

int main()
{
    for (int i = 0; i < Maxm; i++)
        mem[1 << i] = i;
    cin >> n;
    if (n == 1) { cout << "0\n"; return 0; }
    for (int i = 0; i < n; i++)
        cin >> s[i];
    m = s[0].length();
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            for (int k = 0; k < n; k++) if (k != i)
                if (s[i][j] == s[k][j])
                    has[i][j] |= 1ll << ll(k);
    for (int i = 1; i < 1 << m; i++) {
        int pos = mem[i & -i];
        int j = i ^ (1 << pos);
        dp1[i] = dp1[j]; dp2[i] = dp2[j];
        for (int k = 0; k < n; k++)
            if (!(dp1[j] & 1ll << ll(k)) && ((dp1[j] & has[k][pos]) == has[k][pos])) {
                dp1[i] |= 1ll << ll(k); dp2[i]++;
            }
    }
    res[(1 << m) - 1] = 0;
    for (int i = (1 << m) - 2; i >= 0; i--) {
        if (dp2[i] == n) { res[i] = 0; continue; }
        int cnt = 0;
        for (int j = 0; j < m; j++)
            if (!(i & 1 << j)) {
                int ni = i ^ (1 << j);
                res[i] += 1.0 + ld(n - dp2[ni]) / ld(n - dp2[i]) * res[ni];
                cnt++;
            }
        res[i] /= ld(cnt);
    }
    cout << fixed << setprecision(15) << res[0] << endl;
    return 0;
}

using namespace std;
#include <bits/stdc++.h>
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define D(x) cout << #x " = " << (x) << endl
#define endl '\n'

const int MN = 55, MM = 20;
long long dp[(1 << MM) + 2];
double ans[(1 << MM) + 2];
string data[MN];

int s, n;

int main() { ___

  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> data[i];

  s = data[0].size();

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int same = 0;
      for (int k = 0; k < s; ++k)
        if (data[i][k] == data[j][k])
          same |= 1 << k;
      dp[same] = (1LL << j) | (dp[same] | 1LL << i);
    }
  }

  for (int mask = (1 << s) - 1; mask >= 0; --mask)
    for (int i = 0; i < s; ++i)
      if ((mask >> i) & 1)
        dp[mask ^ (1 << i)] |= dp[mask];

  for (int mask = (1 << s) - 1; mask >= 0; --mask) {
    if (dp[mask] == 0)
      ans[mask] = 0;
    else {
      ans[mask] = 0;
      double events = s - __builtin_popcount(mask);
      for (int i = 0; i < s; ++i) {
        if (!((mask >> i) & 1)) {
          ans[mask] += 1.0 + (ans[mask | 1 << i] * (double) __builtin_popcount(dp[mask | 1 << i]) / (long  double)__builtin_popcount(dp[mask]));
        }
      }
      ans[mask] /= events;
    }
  }

  cout << setprecision(15) << ans[0] << endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int m, n, nums[25] = {0};
char strs [50][25];
ll freedom [50][25];
//freedom[i][j]: with string i, upon revealing index j, bitmask for who I can discern
void get_nums(int start, int cnt, ll w_above [50]){
  ll wkset [50];
  if(start == n){
    for(int i = 0; i<m; i++){
      nums[cnt] += w_above[i] == (1<<m)-1;
    }
    return;
  }
  get_nums(start+1, cnt, w_above);
  for(int i = 0; i<m; i++){
    wkset[i] = w_above[i] | freedom[i][start];
  }
  get_nums(start+1, cnt+1, wkset);
}
int main(){
  scanf("%d", &m);
  for(int i = 0; i<m; i++)
    scanf("%s", strs[i]);
  n = strlen(strs[0]);
  for(int i = 0; i<m; i++){
    for(int j = 0; j<n; j++){
      ll r = 0;
      for(int x = 0; x<m; x++){
        r <<= 1;
        r += strs[x][j] != strs[i][j] || i == x;
      }
      freedom[i][j] = r;
    }
  }
  ll start [50] = {0};
  get_nums(0, 0, start);
  /*
  for(int i = 0; i<=n; i++)
    printf("%d ", nums[i]);
  printf("\n");
  */
  double ncr = n;
  double ans = 0;
  for(int i = 1; i<n; i++){
    ans += nums[i] / ncr;
    ncr *= (n-i);
    ncr /= i+1;
  }
  printf("%0.14lf\n", n - ans/m);
}

#include <cstdio>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cctype>
#include <memory.h>

#define pii pair<int,int>
#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;

const int N = 20;
const int MAXN = 1E7;
const int MOD = 1000000007;

int i, j, k, n, m, cnt, diff, diffCnt;
int bitCnt[1 << N];
ll eq[1 << N], fact[N];
double res, ans, prob[N + 1];
string s[51];

int getBitCnt(ll v) {
	return bitCnt[v & ((1 << N) - 1)] + bitCnt[(v >> N) & ((1 << N) - 1)];
}

int main() {
	cin >> n;
	for (i = 0; i < n; i ++) {
		cin >> s[i];
	}
	m = s[0].size();

	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			int mask = 0;
			for (k = 0; k < m; k++) {
				if (s[i][k] == s[j][k])
					mask |= 1 << k;
			}
			eq[mask] |= 1LL << i;
			eq[mask] |= 1LL << j;
		}
	}

	for (i = (1 << m) - 1; i >= 0; i --) {
		for (j = 0; j < m; j++) {
			if (i & (1 << j)) {
				eq[i ^ (1 << j)] |= eq[i];
			}
		}
	}

	bitCnt[0] = 0;
	k = n;
	if (k < m) k = m;
	for (i = 1; i < (1 << k); i++) {
		bitCnt[i] = bitCnt[i & (i - 1)] + 1;
	}

	prob[0] = 1.0;

	for (i = 1; i <= m; i++) {
		prob[i] = prob[i - 1] / (m + 1 - i);
	}

	fact[0] = 1;
	for (i = 1; i < m; i++) {
		fact[i] = fact[i - 1] * i;
	}

	eq[0] = (1 << n) - 1;
	for (i = 0; i < (1<<m); i++)
	for (i = 0; i < (1 << m); i++) {
		for (j = 0; j < m; j++) {
			if (i & (1 << j)) continue;
			cnt = bitCnt[i] + 1;
			diff = eq[i] ^ eq[i ^ (1 << j)];
			diffCnt = getBitCnt(diff);
			ans += fact[cnt - 1] * prob[cnt]  / n * diffCnt * cnt ;
		}
	}
	printf("%.15lf\n", ans);
	return 0;
}

#include <stdio.h>
#include <iostream>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <complex>
#include <ctime>
#include <iomanip>
#include <cassert>
#include <sstream>
#include <iterator>

using namespace std;

#define file "file"
#define mp make_pair
#define pb push_back
#define xx real()
#define yy imag()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<double> point;

const int MAXN = 50 + 5;
const int MAXL = 20 + 5;
const ll MASK = 1ll << 20;

char s[MAXN][MAXL];
ll dp[MASK];
ll res[MAXN];

void solve(){
	int n;
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%s",s[i]);
	}
	int m = strlen(s[0]);
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			ll mask = 0;
			for(int k = 0;k < m;k++){
				if(s[i][k] == s[j][k]){
					mask |= (1ll << k);
				}
			}
			dp[mask] |= 1ll << i;
			dp[mask] |= 1ll << j;
		}
	}
	int b = 1 << m;
	for(int i = b - 1;i >= 0;i--){
		for(int j = 0;j < m;j++){
			if(i & (1 << j)){
				dp[i ^ (1 << j)] |= dp[i];
			}
		}
	}
	double ans = 0;
	int cnt2 = 0,cnt = 0;
	for(int i = 0;i < b;i++){
		cnt = __builtin_popcount(i);
		for(int j = 0;j < m;j++){
			if(i & (1 << j)){
				continue;
			}
			ll dif = dp[i] ^ dp[i ^ (1 << j)];
			if(dif == 0) continue;
		        cnt2 = __builtin_popcount(dif);
			res[cnt + 1] += cnt2;
		}
	}
	for(int i = 1;i <= m;i++){
		double val = res[i];
		for(int j = 0;j < i;j++){
			val *= (1. * i - j) / (m - j);
		}
		ans += val;
	}
	ans /= n;
	printf("%.12lf",ans);
}

int main()
{
	#ifndef ONLINE_JUDGE
    assert(freopen("input.txt","r",stdin));
    assert(freopen("output.txt","w",stdout));
    #else
    //assert(freopen(file".in","r",stdin)); assert(freopen(file".out","w",stdout));
    #endif
	int t = 1;
	while(t--){
		solve();
	}
	return 0;
}