#include <bits/stdc++.h>
using namespace std;
vector<int> v[3005];
bool vis[3005], cir[3005];
int q, s, n;
int Find_Cir(int x, int y) {
  vis[x] = 1;
  for (int i = 0; i < v[x].size(); i++)
    if (!vis[v[x][i]]) {
      int t = Find_Cir(v[x][i], x);
      if (t) {
        if (t > 0) {
          cir[x] = 1;
          s++;
        }
        return t == x ? -1 : t;
      }
    } else if (v[x][i] != y) {
      cir[x] = s = 1;
      return v[x][i];
    }
}
double ans;
void Dfs(int x) {
  vis[x] = 1;
  q += cir[x];
  n++;
  if (q > 1) {
    int c = n - q + s, a = q - 2, b = s - q;
    ans += (double)a / c / (c - a) + (double)b / c / (c - b) + 1.0 / c;
  } else
    ans += 1.0 / n;
  for (int i = 0; i < v[x].size(); i++)
    if (!vis[v[x][i]]) Dfs(v[x][i]);
  n--;
  q -= cir[x];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1, x, y; i <= n; i++)
    scanf("%d%d", &x, &y), v[x + 1].push_back(y + 1), v[y + 1].push_back(x + 1);
  Find_Cir(1, 0);
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    Dfs(i);
  }
  printf("%.20lf\n", ans);
}
