#include <bits/stdc++.h>
typedef long long ll;
#define int long long
inline ll read() {
    char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
    ll k = 0, kk = 1;
	if (c == '-') c = getchar() , kk = -1;
    while (c >= '0' && c <= '9') k = k * 10 + c - '0', c = getchar();
	return kk * k;
}
void write(ll x) {
	if (x < 0) x = -x, putchar('-');
	if (x / 10) write(x / 10);
	putchar(x % 10 + '0');
}
void writeln(ll x) {write(x); puts("");}
using namespace std;
int n,x,y,a[1000010],b[1000010],da,db;
signed main() {
	int t=read();while (t--){
		n = read();da=db=0;
		for (int i = 1; i <= n * 2; i++) {
			x = read();
			y = read();
			if (x == 0) {
				a[++da] = abs(y);
			} else {
				b[++db] = abs(x);
			}
		}
		sort(a+1,a+1+n);sort(b+1,b+1+n);
		double ans=0;
		for (int i=1;i<=n;i++) {
			ans+=sqrt(a[i]*a[i]+b[i]*b[i]);
		}printf("%.20lf\n",ans);
	}
	return 0;
}
