#include <iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<climits>
#include <iomanip>
#define ll long long
#include<cmath>
using namespace std;
int compare(int &a, int &b) {
	return a > b;
}
double distance(ll x1, ll x2) {
	return sqrt(x2 * x2 * 1.00 + x1 * x1 * 1.00);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("ou.txt", "w", stdout);
#endif
	int t; cin >> t;
	while (t--) {
		int n; cin >> n;
		vector<ll> v, v1;
		int ans = 2 * n;
		while (ans--) {
			ll a, b; cin >> a >> b;
			if (a == 0)
				v.push_back(abs(b));
			else {
				v1.push_back(abs(a));
			}
		}
		sort(v1.begin(), v1.end());
		sort(v.begin(), v.end());
		double sum = 0;
		for (int i = 0; i < n; i++) {
			sum += distance(v[i], v1[i]);

		}
		cout << setprecision(15) << sum << endl;


	}

}