#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

typedef pair<int ,int>pii;
vector<int>a, b;
const int maxn = 5e5 + 555;
int saveori[maxn];

double cal(int a, int b){
    return sqrt(a * a + b * b);
}

void solve(){
    a.clear();
    b.clear();
    int n;
    scanf("%lld", &n);
    for(int i =1; i<= 2 * n ;i++){
        int aa, bb;
        scanf("%lld %lld", &aa, &bb);
        aa = abs(aa);
        bb = abs(bb);
        if(bb == 0)
            a.push_back(aa);
        else if (aa == 0)
            b.push_back(bb);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    double ans = 0;
    for(int i =0 ; i<n; i++){
        ans += cal(a[i], b[i]);
    }
    printf("%.10lf\n", ans);
}

signed main(){
    //freopen("in.txt", "r", stdin);
    int T = 1;
    cin>>T;
    while(T--)
        solve();
}
