#include<bits/stdc++.h>
using namespace std;
#define RI register int
typedef double db;
const int N=3005;
int n,tot,top,cnt;db ans;
int h[N],ne[N<<1],to[N<<1],vis[N],in_c[N],stk[N],cir[N];
int dep[N],id[N],fa[N][12],c_d1[N][N],c_d2[N][N];

void add(int x,int y) {to[++tot]=y,ne[tot]=h[x],h[x]=tot;}
void find_circle(int x,int las) {
	vis[x]=1,stk[++top]=x;
	for(RI i=h[x];i;i=ne[i]) {
		if(to[i]==las) continue;
		if(vis[to[i]]) {
			if(in_c[x]) continue;
			for(RI j=top;;--j) {
				in_c[stk[j]]=1,cir[++cnt]=i;
				if(stk[j]==to[i]) break;
			}
		}
		else find_circle(to[i],x);
	}
	--top;
}
void work_circle() {
	for(RI i=1;i<=cnt;++i)
		for(RI j=i+1;j<=cnt;++j) {
			c_d1[cir[i]][cir[j]]=c_d1[cir[j]][cir[i]]=j-i-1;
			c_d2[cir[i]][cir[j]]=c_d2[cir[j]][cir[i]]=i-1+cnt-j;
		}
}
void dfs(int x,int rt,int d,int las) {
	dep[x]=d,id[x]=rt,fa[x][0]=las;
	for(RI i=1;i<=11;++i) fa[x][i]=fa[fa[x][i-1]][i-1];
	for(RI i=h[x];i;i=ne[i])
		if(to[i]!=las&&!in_c[to[i]]) dfs(to[i],x,d+1,x);
}
int lca(int x,int y) {
	if(dep[x]<dep[y]) swap(x,y);
	for(RI i=11;i>=0;--i) if(dep[fa[x][i]]>=dep[y]) x=fa[x][i];
	if(x==y) return x;
	for(RI i=11;i>=0;--i)
		if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}

int main()
{
	int x,y;
	scanf("%d",&n);
	for(RI i=1;i<=n;++i)
		scanf("%d%d",&x,&y),++x,++y,add(x,y),add(y,x);
	find_circle(1,0),work_circle();
	for(RI i=1;i<=n;++i) if(in_c[i]) dfs(i,i,0,0);
	for(RI i=1;i<=n;++i)
		for(RI j=1;j<=n;++j) {
			if(id[i]==id[j])
				ans+=1.0/(db)(dep[i]+dep[j]-2*dep[lca(i,j)]+1);
			else {
				int a=c_d1[id[i]][id[j]],b=c_d2[id[i]][id[j]];
				int c=dep[i]+1+dep[j]+1;
				ans+=(1.0/(db)(a+c)+1.0/(db)(b+c)-1.0/(db)(a+b+c));
			}
		}
	printf("%.8lf\n",ans);
	return 0;
}