#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
		long long n;
		cin>>n;
		vector<long long> a,b;
		for(int i=0;i<2*n;i++)
		{
			long long x,y;
			cin>>x>>y;
			if(x<0)
			x=-(x);
			else if(y<0)
			y=-(y);
			if(y==0)
			a.push_back(x);
			else
			b.push_back(y);
		}
		
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		double sum=0;
	for(int i=0;i<n;i++)
	{
	sum=sum + (sqrt((a[i]*a[i]) + (b[i]*b[i])));	
	}
	cout<<setprecision(15)<<sum<<endl;
	}
	return 0;
}