#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
inline void read(int& x){
	static char c;
	while(!isdigit(c=getchar())); x=c^48;
	while(isdigit(c=getchar()))x=(x*10)+(c^48);
}
inline void read(ll& x){
	static char c;
	while(!isdigit(c=getchar())); x=c^48;
	while(isdigit(c=getchar()))x=(x*10)+(c^48);
}

const int N=1e5+10;
int T,n;
vector<int> X,Y;

void Work(){
	read(T);
	while(T--){
		read(n);
		int _x,_y;
		X.clear(),Y.clear();
		for(int i=1;i<=2*n;++i){
			scanf("%d%d",&_x,&_y);
			if(!_x) Y.pb(abs(_y));
			if(!_y) X.pb(abs(_x));
		}
		sort(Y.begin(),Y.end());
		sort(X.begin(),X.end());
		double Ans=0;
		for(int i=0;i<n;++i) Ans+=sqrt(1.0*X[i]*X[i]+1.0*Y[i]*Y[i]);
		printf("%.9lf\n",Ans);
	}
}

int main(){Work();}

