#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
int To[MAXN * 2], Next[MAXN * 2], Final[MAXN], tot;
int Circle[MAXN], Deep[MAXN], Fa[MAXN][MAXN], Lst[MAXN], Top[MAXN], P[MAXN], N,
    Up, Down;
void Link(int u, int v) { To[++tot] = v, Next[tot] = Final[u], Final[u] = tot; }
int Get(int a) { return Top[a] == a ? a : Top[a] = Get(Top[a]); }
void Dfs(int Now, int Pre) {
  Deep[Now] = Deep[Pre] + 1;
  Top[Now] = Now;
  for (int i = Final[Now]; i; i = Next[i])
    if (To[i] != Pre) {
      if (Deep[To[i]] > Deep[Now]) continue;
      if (Deep[To[i]]) {
        Up = To[i], Down = Now;
        continue;
      } else
        Lst[To[i]] = Now, Dfs(To[i], Now), Top[To[i]] = Now;
    }
  for (int i = 1; i <= N; i++)
    if (Top[i]) {
      Fa[Now][i] = Fa[i][Now] = Get(i);
    }
}
void Mark(int Now, int Cir) {
  if (!Circle[Now]) Circle[Now] = Cir;
  for (int i = Final[Now]; i; i = Next[i])
    if (!Circle[To[i]]) Mark(To[i], Circle[Now]);
}
int Dis(int u, int v) { return Deep[u] + Deep[v] - 2 * Deep[Fa[u][v]] + 1; }
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u++, v++;
    Link(u, v), Link(v, u);
  }
  Dfs(1, 0);
  int cnt = 0;
  for (int cur = Down;; cur = Lst[cur]) {
    Circle[cur] = cur;
    P[++cnt] = cur;
    if (cur == Up) break;
  }
  for (; cnt; cnt--) Mark(P[cnt], P[cnt]);
  double Ans = 0;
  for (int x = 1; x <= N; x++)
    for (int y = 1; y <= N; y++) {
      if (x == y)
        Ans = Ans + 1;
      else {
        int i = x, j = y;
        if (Circle[i] == Circle[j])
          Ans += 1.0 / Dis(i, j);
        else {
          int X = Dis(Circle[j], j) + Dis(Circle[i], i);
          if (Deep[Circle[j]] < Deep[Circle[i]]) swap(i, j);
          int Y = Dis(Circle[i], Circle[j]) - 2,
              Z = Dis(Circle[j], Down) + Dis(Up, Circle[i]) - 2;
          Ans += 1.0 / (X + Y) + 1.0 / (X + Z) - 1.0 / (X + Y + Z);
        }
      }
    }
  printf("%.11f\n", Ans);
}
