#include <bits/stdc++.h>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for(int k = 0; k < t; k++)
	{
		int n;
		cin >> n;
		vector<int> miners;
		vector<int> diamonds;
		long double ans = 0;
		for(int i = 0; i < 2*n; i++)
		{
			int a, b;
			cin >> a >> b;
			if(a == 0)
				miners.push_back(abs(b));
			else
				diamonds.push_back(abs(a));
		}

		sort(miners.begin(), miners.end());
		sort(diamonds.begin(), diamonds.end());
		for(int i = 0; i < n; i++)
		{
			ans += sqrt(pow(miners[i], 2) + pow(diamonds[i], 2));
		}
		printf("%.9Lf\n", ans);
	}
	return 0;
}