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

int N;
vector<long long> diamond, miner;

int mabs(int x) {
   return x < 0 ? -x : x;
}

int main() {
   int t; scanf("%d", &t);
   for(int cs = 1; cs <= t; cs++) {
      scanf("%d", &N);
      diamond.clear(); miner.clear();
      for(int i = 0; i < 2 * N; i++) {
         int x, y; scanf("%d%d", &x, &y);
         x = mabs(x); y = mabs(y);
         if(x == 0) diamond.push_back(y);
         else miner.push_back(x);
      }
      sort(diamond.begin(), diamond.end());
      sort(miner.begin(), miner.end());

      long double res = 0.0;
      for(int i = 0; i < N; i++) {
         res += hypotl(diamond[i], miner[i]);
      }
      printf("%.12lf\n", (double)res);
   }
}

