#include<algorithm>
#include<cstdio>
#include<cmath>
#define ll long long
#define MaxN 100500
using namespace std;
int n;
ll x[MaxN],y[MaxN];
void solve()
{
  scanf("%d",&n);
  int n1=0,n2=0;
  for (int i=1,_x,_y;i<=n+n;i++){
    scanf("%d%d",&_x,&_y);
    if (!_x)y[++n2]=1ll*_y*_y;
    else x[++n1]=1ll*_x*_x;
  }sort(x+1,x+n+1);sort(y+1,y+n+1);
  double ans=0.0;
  for (int i=1;i<=n;i++)
    ans+=sqrt(x[i]+y[i]);
  printf("%.12lf\n",ans);
}
int main()
{
  int T;scanf("%d",&T);
  while(T--)solve();
  return 0;
}
