#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define N 3100
using namespace std;
int head[N],next[N*2],bfs[N],du[N],e[N*2],len,dis[N],dis2[N],b[N],n,i,x,y,l,r,circle,j;
double ans;
void dfs(int x){
	b[x]=1;
	for(int i=head[x];i;i=next[i])if(!b[e[i]]){
		if(!dis[e[i]])dis[e[i]]=dis[x]+1;
		dis2[e[i]]=dis2[x]+1;
		dfs(e[i]);
	}
	b[x]=0;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d%d",&x,&y);
		x++; y++;
		next[++len]=head[x]; head[x]=len; e[len]=y;
		next[++len]=head[y]; head[y]=len; e[len]=x;
		du[x]++; du[y]++;
	}
	l=1; r=0;
	for(i=1;i<=n;++i)if(du[i]==1)bfs[++r]=i;
	while(l<=r){
		x=bfs[l++];
		for(i=head[x];i;i=next[i])if((--du[e[i]])==1)
			bfs[++r]=e[i];
	}
	circle=n-r;
	for(i=1;i<=n;++i){
		memset(dis,0,sizeof(dis)); memset(dis2,0,sizeof(dis2));
		dis[i]=dis2[i]=1;
		dfs(i);
		for(j=1;j<=n;++j){
			if(dis[j]==dis2[j])ans+=1.0/dis[j];
			else ans+=1.0/dis[j]+1.0/dis2[j]-1.0/( (dis[j]+dis2[j]+circle-2)/2 );
		}
	}
	printf("%.10lf\n",ans);
}
