#include <bits/stdc++.h>

using namespace std;

long long workers[100005], diamonds[100005];

void solve()
{
    int n;
    cin >> n;
    int j1 = 0, j2 = 0;
    for (int i = 0; i < 2 * n; ++i)
    {
        long long x, y;
        cin >> x >> y;
        if (!x)
            workers[j1++] = abs(y);
        else
            diamonds[j2++] = abs(x);
    }
    sort(workers, workers + n);
    sort(diamonds, diamonds + n);
    long double res = 0;
    for (int i = n - 1; i >= 0; --i)
        res += sqrt(workers[i] * workers[i] + diamonds[i] * diamonds[i]);
    cout << fixed << setprecision(9) << res << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}
