#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
struct E {
  int next, to;
} e[N << 1];
int head[N], tot, q, s, n;
void add(int x, int y) {
  e[++tot].to = y;
  e[tot].next = head[x];
  head[x] = tot;
  e[++tot].to = x;
  e[tot].next = head[y];
  head[y] = tot;
}
bool v[N], cir[N];
int Find_circle(int x, int fa) {
  v[x] = true;
  for (int i = head[x]; i; i = e[i].next)
    if (!v[e[i].to]) {
      int tmp = Find_circle(e[i].to, x);
      if (tmp) {
        if (tmp > 0) {
          cir[x] = true;
          s++;
        }
        return tmp == x ? -1 : tmp;
      }
    } else if (e[i].to != fa) {
      cir[x] = s = 1;
      return e[i].to;
    }
}
double ans;
void dfs(int x) {
  v[x] = true;
  q += cir[x];
  n++;
  if (q > 1) {
    int a = q - 2, b = s - q, c = n - q + s;
    ans += (double)a / c / (c - a) + (double)b / c / (c - b) + 1.0 / c;
  } else
    ans += 1.0 / n;
  for (int i = head[x]; i; i = e[i].next)
    if (!v[e[i].to]) dfs(e[i].to);
  n--;
  q -= cir[x];
}
int main() {
  int n;
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    x++, y++;
    add(x, y);
  }
  Find_circle(1, 0);
  for (int i = 1; i <= n; i++) {
    memset(v, 0, sizeof(v));
    dfs(i);
  }
  printf("%.12f", ans);
  return 0;
}
