
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <immintrin.h>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <random>
#include <ctime>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
#define mp make_pair
#define pb push_back
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repb(i, n) for (ll i = n - 1; i>=0; --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const ll inf = 1e9;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MAXN = 1e5;

inline void SOLVE() {
    int n;
    cin >> n;
    vector<ll> miners;
    vector<ll> diamonds;
    rep(i, 2 * n) {
        ll x, y;
        cin >> x >> y;
        x = abs(x);
        y = abs(y);
        if (x == 0)
            miners.pb(y);
        else
            diamonds.pb(x);
    }
    sort(all(miners));
    sort(all(diamonds));
    ld s = 0;
    rep(i, n) {
        s += sqrt(miners[i] * miners[i] + diamonds[i] * diamonds[i]);
    }
    cout << fixed << setprecision(9);
    cout << s << '\n';
}

inline void IQ() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
}

signed main() {
#ifdef GOSHA
    freopen("../IO/input.txt", "r", stdin);
    freopen("../IO/output.txt", "w", stdout);
#endif
    IQ();
    ll T = 1;
    cin >> T;
    while (T--) {
        SOLVE();
    }
    return 0;
}