#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define N 3100
int root[N],dep[N],fa[N][15],head[N],v[N*2],next[N*2],num=0,du[N],lab[N],n,X[N],Y[N],q[N];
double ans=0;
bool vis[N];
void add(int x,int y){
     v[++num]=y;next[num]=head[x];head[x]=num;
     }
void dfs(int u,int D,int Rt){
     vis[u]=1;
     for(int i=1;(1<<i)<=D;i++)fa[u][i]=fa[fa[u][i-1]][i-1];
     root[u]=Rt;dep[u]=D;
     for(int i=head[u];i;i=next[i])
       if(du[v[i]]==1 && !vis[v[i]]){
             fa[v[i]][0]=u;
             dfs(v[i],D+1,Rt);
             }
}
void Dfs(int st,int u,int len){
     if(du[u]==1 || vis[u])return;
     lab[u]=len;vis[u]=1;
     for(int i=head[u];i;i=next[i])
       Dfs(st,v[i],len+1);
}
int lca(int x,int y){
    int ans=1;
    if(dep[x]<dep[y])swap(x,y);
    for(int i=13;i>=0;i--)
      if((1<<i)<=(dep[x]-dep[y]))ans+=1<<i,x=fa[x][i];
    if(x==y)return ans;
    for(int i=13;i>=0;i--)
      if((1<<i)<=dep[x] && fa[x][i]!=fa[y][i])x=fa[x][i],y=fa[y][i],ans+=1<<i;
    return ans+2;
}
int main(){
    scanf("%d",&n);
    memset(head,0,sizeof head);num=0;
    for(int i=1;i<=n;i++){
      scanf("%d%d",&X[i],&Y[i]);
      ++X[i];++Y[i];
      add(X[i],Y[i]);add(Y[i],X[i]);
      du[X[i]]++;
      du[Y[i]]++;
    }
    int t=0,w=0,sum=0;num=0;
    for(int i=1;i<=n;i++)
      if(du[i]==1)q[++w]=i;
    while(t<w){
      int u=q[++t];
      for(int i=head[u];i;i=next[i])
        if(du[v[i]]>1){
        --du[v[i]];
        if(du[v[i]]==1)q[++w]=v[i];
      }
    }
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++)
      if(du[i]>1){Dfs(i,i,0);break;}
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++)
      if(du[i]>1)dfs(i,0,i),++sum;
   // for(int i=1;i<=n;i++)printf("%d ",fa[i][0]);printf("\n");
   // for(int i=1;i<=n;i++)printf("%d ",lab[i]);printf("\n");
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++){
              double tt=ans;
        if(root[i]==root[j]){
          int tt=lca(i,j);
         // printf("%d %d --> %d\n",i-1,j-1,tt);
          ans+=1.0/lca(i,j);
          }
        else{
          int l1=lca(i,root[i]),l2=lca(j,root[j]),t1=lab[root[i]]-lab[root[j]],t2=-t1;
          t1=(t1%sum+sum)%sum+1;
          t2=(t2%sum+sum)%sum+1;
          ans+=(1.0/(l1+t1+l2-2))+(1.0/(l1+t2+l2-2))-(1.0/(sum+l1+l2-2));
        //  printf("%d %d --> %d %d %d\n",i-1,j-1,l1+t1+l2-2,l1+t2+l2-2,sum+l1+l2-2);
        }
     //   printf("%.7lf\n",ans-tt);
        }
    printf("%.8lf\n",ans);
    return 0;
}
