#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s;
}
const int N = 10100;
int n, head[N], vis[N], tt, sta[N], tp, tmp, c[N], h, usd[N], rev[N], ne[N],
    id[N];
int nx[N], sz[N], top[N], fa[N], dis[N];
struct pr {
  int next, to;
} a[N];
void add(int u, int v) {
  a[++tt] = (pr){head[u], v};
  head[u] = tt;
}
void dfs(int x, int fa) {
  vis[x] = 1;
  sta[++tp] = x;
  for (int i = head[x]; i; i = a[i].next) {
    int y = a[i].to;
    if (y == fa) continue;
    if (vis[y] && !tmp) {
      tmp = 1;
      while (sta[tp + 1] != y) {
        usd[sta[tp]] = 1;
        c[++h] = sta[tp];
        rev[c[h]] = h;
        tp--;
      }
    }
    if (!vis[y]) dfs(y, x);
  }
  tp--;
}
void getne(int x, int FA, int ID) {
  id[x] = ID;
  fa[x] = FA;
  sz[x] = 1;
  for (int i = head[x]; i; i = a[i].next) {
    int y = a[i].to;
    if (usd[y]) continue;
    if (y == FA) continue;
    dis[y] = dis[x] + 1;
    getne(y, x, ID);
    sz[x] += sz[y];
    if (sz[y] > sz[nx[x]]) nx[x] = y;
  }
}
void dfs1(int x) {
  if (nx[x]) {
    top[nx[x]] = top[x];
    dfs1(nx[x]);
  }
  for (int i = head[x]; i; i = a[i].next) {
    int y = a[i].to;
    if (usd[y] || y == fa[x] || y == nx[x]) continue;
    top[y] = y;
    dfs1(y);
  }
}
int lca(int x, int y) {
  while (top[x] != top[y]) {
    if (dis[top[x]] > dis[top[y]])
      x = fa[top[x]];
    else
      y = fa[top[y]];
  }
  if (dis[x] > dis[y]) swap(x, y);
  return x;
}
int main() {
  long double ans = 1e9;
  n = read();
  for (int i = 1; i <= n; i++) {
    int x = read() + 1, y = read() + 1;
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    if (rev[i]) getne(i, 0, i), top[i] = i, dfs1(i);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (id[i] != id[j]) {
        ans += 1.0 / (dis[i] + dis[j] + abs(rev[id[i]] - rev[id[j]]) + 1);
        ans += 1.0 / (dis[i] + dis[j] + (h - abs(rev[id[i]] - rev[id[j]])) + 1);
        ans -= 1.0 / (dis[i] + dis[j] + h);
      } else {
        int t = lca(i, j);
        ans += 1.0 / (dis[i] + dis[j] - dis[t] * 2 + 1);
      }
    }
  }
  printf("%.7Lf\n", ans - 1e9);
}
