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

int main(){
     int i, j, k;
     int t;
     cin >> t;
     while(t--){
          int n;
          cin >> n;
          vector<double> mine, miner;
          for(i=0; i<2*n; ++i){
               int x, y;
               cin >> x >> y;
               if(x==0) miner.push_back(abs(y));
               else mine.push_back(abs(x));
          }
          sort(mine.begin(), mine.end());
          sort(miner.begin(), miner.end());
          double res=0;
          for(i=0; i<n; ++i){
               //cout << mine[i] << " " << miner[i] << endl;
               res+=sqrt(mine[i]*mine[i]+miner[i]*miner[i]);
          }
          cout << setprecision(12) << fixed << res << endl;
     }
}
