#include <bits/stdc++.h>

using namespace std;

#define  ll long long
#define ld long double
#define f first
#define s second

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

    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        vector< pair<ll,ll> > vX , vY;
        for(int i=1; i<=2*n; i++)
        {
            ll x , y;
            cin >> x >> y;
            if (x==0) //miner
            {
                if (y < 0) vY.push_back({abs(y) , 0});
                else vY.push_back({y,1});
            }
            else
            {
                if (x < 0) vX.push_back({abs(x) , 0});
                else vX.push_back({x , 1});
            }
        }
        sort(vX.begin() , vX.end());
        sort(vY.begin() , vY.end());

        ld ans = 0 , tmp;

        for(int i=0; i<n; i++)
        {
            tmp = sqrt(vX[i].f*vX[i].f + vY[i].f*vY[i].f);
            ans += tmp;
        }

        cout << fixed << setprecision(12) << ans << '\n';
    }

    return 0;
}