/*
* @Author: Akash
* @Date:   2021-03-12 08:23:51
* @Last Modified by:   Akash
* @Last Modified time: 2021-03-12 09:00:56
*/

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	int t;
	cin >> t;

	while(t--){
		int miners, minersTwice;
		vector<int> minersPos, minesPos;
		cin >> miners;
		minersTwice = 2*miners;

		while(minersTwice--){
			int posX, posY;
			cin >> posX >> posY;
			if(posX == 0){
				minersPos.push_back(abs(posY));
			} else{
				minesPos.push_back(abs(posX));
			}
		}
		sort(minersPos.begin(), minersPos.end());
		sort(minesPos.begin(), minesPos.end());		

		double cost = 0;
		for(int i=0;i<minersPos.size();i++){
			cost+=sqrt(1.0*minersPos[i]*minersPos[i]+1.0*minesPos[i]*minesPos[i]);
		}
		cout.precision(15);
		cout << cost << "\n";
		//printf("%.15lf\n", cost);
	}

	return 0;
}