#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define ll long long
#define int long long
inline ll read(){ll x=0,f=1;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-f;for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';return x*f;}
inline void write(ll x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
const int N=100005;
int a[N],b[N];
void solve()
{
	int n=read();
	int ca,cb;
	ca=cb=0;
	for(int i=1;i<=2*n;i++){
		int x,y;
		x=read();y=read();
		if(x==0)a[++ca]=abs(y);
		if(y==0)b[++cb]=abs(x);
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	long double ans=0;
	for(int i=1;i<=n;i++)
		ans=ans+sqrt(1.0*(a[i]*a[i])+(b[i]*b[i]));
	printf("%.16Lf\n",ans);
	return;
}
signed main()
{
	int t=read();
	while(t--){
		solve();
	} 
}

