#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include using namespace atcoder; int main() { fast_io(); int n; cin >> n; vector> xy(n); vector vals; for (int i = 0; i < n; i++) { cin >> xy[i].first >> xy[i].second; vals.push_back(xy[i].first); vals.push_back(xy[i].second); } sort(vals.begin(), vals.end()); vals.erase(unique(vals.begin(), vals.end()), vals.end()); int m = vals.size(); for (int i = 0; i < n; i++) { xy[i].first = lower_bound(vals.begin(), vals.end(), xy[i].first) - vals.begin(); xy[i].second = lower_bound(vals.begin(), vals.end(), xy[i].second) - vals.begin(); } long long r = (long long)n * (n - 1) / 2, s = r; { vector cnt_x(m), cnt_y(m); for (auto [x, y] : xy) { r -= cnt_x[x]; cnt_x[x]++; s -= cnt_y[y]; cnt_y[y]++; } } long long p = 0; { sort(xy.begin(), xy.end(), [&](auto a, auto b) { if (a.first == b.first) return a.second > b.second; return a.first < b.first; }); fenwick_tree fw(m); for (auto [_, y] : xy) { p += fw.sum(0, y); fw.add(y, 1); } } long long q = 0; { sort(xy.begin(), xy.end(), [&](auto a, auto b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; }); fenwick_tree fw(m); for (auto [_, y] : xy) { q += fw.sum(y + 1, m); fw.add(y, 1); } } long double ans = (p - q) / sqrtl(r) / sqrtl(s); cout << fixed << setprecision(16) << ans << endl; }