#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define N 3005
#define LL long long
#define oo (1<<30)
using namespace std;
double ans;
int n,len,f[N],head[N],num[N],next[N],tag[N],vis[N],a[N],b[N],cir;
int find(int x){ return f[x] ? f[x]=find(f[x]) : x;}
void link(int x,int y)
{
	num[++len]=y,next[len]=head[x],head[x]=len;
}
bool search(int x,int fa,int y)
{
	int i;
	if(x==y) return 1;
	for(i=head[x];i;i=next[i])
		if(num[i]!=fa){
			tag[i]=tag[i^1]=1,cir++;
			if(search(num[i],x,y)) return 1;
			tag[i]=tag[i^1]=0,cir--;
		  }
	return 0;
}
void dfs(int t,int fa,int A,int B)
{
	int i; a[t]=A,b[t]=B;
	for(i=head[t];i;i=next[i])
		if(num[i]!=fa)
			dfs(num[i],t,A+1,B+tag[i]);
}
int main()
{
	int i,j,x,y; len=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d %d",&x,&y),x++,y++;
		if(find(x)!=find(y))
			f[find(x)]=find(y),link(x,y),link(y,x);
		else
			search(x,0,y);
	  }
	cir++;
	for(i=1;i<=n;i++){
		dfs(i,0,0,0);
		for(j=1;j<=n;j++)
			if(j!=i){
				if(!b[j]) ans+=1.0/(a[j]+1);
				else ans+=1.0/(a[j]+1)+1.0/(a[j]-2*b[j]+cir+1)-1.0/(a[j]-b[j]+cir);
			  }
		ans++;
		}
	printf("%.9lf",ans);
	return 0;
}
