#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
 
int main(){
    ll t;
	cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		vector<double>v1;
		vector<double>v2;
		ll x, y;
		for (ll i = 0; i < 2 * n; i++)
		{
			cin >> x >> y;
			if (x == 0)
				v1.pb(abs(y));
			else
				v2.pb(abs(x));
		}
		sort(v1.begin(), v1.end());
		sort(v2.begin(), v2.end());
		double sum = 0;
		for (ll i = 0; i < n; i++)
		{
			sum = sum + sqrt(v1[i] * v1[i] + v2[i] * v2[i]);
		}
		cout << fixed << setprecision(9) << sum << endl;
	}
    return 0;
}