Diamond Miner is a game that is similar to Gold Miner, but there are $n$ miners instead of $1$ in this game.

The mining area can be described as a plane. The $n$ miners can be regarded as $n$ points on the y-axis. There are $n$ diamond mines in the mining area. We can regard them as $n$ points on the x-axis. For some reason, no miners or diamond mines can be at the origin (point $(0, 0)$).

Every miner should mine exactly one diamond mine. Every miner has a hook, which can be used to mine a diamond mine. If a miner at the point $(a,b)$ uses his hook to mine a diamond mine at the point $(c,d)$, he will spend $\sqrt{(a-c)^2+(b-d)^2}$ energy to mine it (the distance between these points). The miners can't move or help each other.

The object of this game is to minimize the sum of the energy that miners spend. Can you find this minimum?


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1\le t\le 10$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($1 \le n \le 10^5$) — the number of miners and mines.

Each of the next $2n$ lines contains two space-separated integers $x$ ($-10^8 \le x \le 10^8$) and $y$ ($-10^8 \le y \le 10^8$), which represent the point $(x,y)$ to describe a miner's or a diamond mine's position. Either $x = 0$, meaning there is a miner at the point $(0, y)$, or $y = 0$, meaning there is a diamond mine at the point $(x, 0)$. There can be multiple miners or diamond mines at the same point.

It is guaranteed that no point is at the origin. It is guaranteed that the number of points on the x-axis is equal to $n$ and the number of points on the y-axis is equal to $n$.

It's guaranteed that the sum of $n$ for all test cases does not exceed $10^5$.


-----Output-----

For each test case, print a single real number — the minimal sum of energy that should be spent.

Your answer is considered correct if its absolute or relative error does not exceed $10^{-9}$.

Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-9}$.


-----Examples-----

Input
3
2
0 1
1 0
0 -1
-2 0
4
1 0
3 0
-5 0
6 0
0 3
0 1
0 2
0 4
5
3 0
0 4
0 -3
4 0
2 0
1 0
-3 0
0 -10
0 -2
0 -10
Output
3.650281539872885
18.061819283610362
32.052255376143336


-----Note-----

In the first test case, the miners are at $(0,1)$ and $(0,-1)$, while the diamond mines are at $(1,0)$ and $(-2,0)$. If you arrange the miners to get the diamond mines in the way, shown in the picture, you can get the sum of the energy $\sqrt2 + \sqrt5$.

Source: codeforces | Difficulty: EASY
Tags: Geometry

Sorting

Mathematics

Greedy algorithms


Solutions:
import math
from collections import Counter
from collections import defaultdict
import copy
t = int(input())
for _ in range(t):
	n = int(input())
	mine = []
	di = []
	for i in range(2 * n):
		(x, y) = [int(i) for i in input().split()]
		if x == 0:
			mine.append(abs(y))
		else:
			di.append(abs(x))
	mine.sort()
	di.sort()
	ans = 0
	for i in range(n):
		ans += math.sqrt(mine[i] * mine[i] + di[i] * di[i])
	print(ans)


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	miners = []
	mines = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x:
			miners.append(abs(x))
		else:
			mines.append(abs(y))
	miners.sort()
	mines.sort()
	d = 0
	for i in range(n):
		d += (miners[i] ** 2 + mines[i] ** 2) ** 0.5
	print(d)


t = int(input())
for _ in range(t):
	n = int(input())
	(xs, ys) = ([], [])
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			ys.append(y * y)
		else:
			xs.append(x * x)
	xs.sort()
	ys.sort()
	dist = 0
	for (a, b) in zip(xs, ys):
		dist += (a + b) ** 0.5
	print(dist)


import math
t = int(input())
for i in range(t):
	n = int(input())
	distancias = []
	pos_x = []
	pos_y = []
	for j in range(n):
		pos_xy = input()
		pos_xy = pos_xy.split()
		if int(pos_xy[0]) != 0:
			pos_x.append(abs(int(pos_xy[0])))
		else:
			pos_y.append(abs(int(pos_xy[1])))
		mina_xy = input()
		mina_xy = mina_xy.split()
		if int(mina_xy[0]) != 0:
			pos_x.append(abs(int(mina_xy[0])))
		else:
			pos_y.append(abs(int(mina_xy[1])))
	pos_x.sort()
	pos_y.sort()
	for j in range(n):
		distancia = math.sqrt(pos_x[j] ** 2 + pos_y[j] ** 2)
		distancias.append(distancia)
	soma = 0
	for j in range(n):
		soma += distancias[j]
	print(soma)


for _ in range(int(input())):
	n = int(input())
	miners = []
	diamond = []
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miners.append(abs(y))
		else:
			diamond.append(abs(x))
	miners.sort()
	diamond.sort()
	ans = 0
	for i in range(len(miners)):
		(x, y) = (miners[i], diamond[i])
		ans += (x ** 2 + y ** 2) ** 0.5
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			y.append(abs(b))
		else:
			x.append(abs(a))
	x.sort()
	y.sort()
	ans = 0
	for i in range(n):
		ans += (x[i] * x[i] + y[i] * y[i]) ** 0.5
	print(ans)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, points):
	miners = []
	mines = []
	for (x, y) in points:
		if x == 0:
			miners.append(y)
		elif y == 0:
			mines.append(x)
	miners.sort(key=lambda x: abs(x))
	mines.sort(key=lambda x: abs(x))
	ans = 0.0
	for (x, y) in zip(miners, mines):
		ans += (x * x + y * y) ** 0.5
	return ans
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	points = [[int(x) for x in input().split()] for i in range(2 * N)]
	ans = solve(N, points)
	print(ans)


import math

def main():
	t = int(input())
	while t:
		t -= 1
		n = int(input())
		soma = 0
		mina = []
		mineiro = []
		for i in range(2 * n):
			entrada = input().split(' ')
			x = int(entrada[0])
			y = int(entrada[1])
			if x == 0:
				mineiro.append(abs(y))
			else:
				mina.append(abs(x))
		mineiro.sort()
		mina.sort()
		for i in range(n):
			soma += math.sqrt(mina[i] * mina[i] + mineiro[i] * mineiro[i])
		print(soma)
main()


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	X = []
	Y = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			Y.append(abs(y))
		else:
			X.append(abs(x))
	X.sort()
	Y.sort()
	ANS = 0
	for i in range(n):
		ANS += (X[i] ** 2 + Y[i] ** 2) ** (1 / 2)
	print(ANS)


from math import sqrt
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(miners, mines) = ([], [])
	for _ in range(int(input()) * 2):
		(x, y) = map(int, input().split())
		if x == 0:
			miners.append(abs(y))
		else:
			mines.append(abs(x))
	ans = sum((sqrt(x * x + y * y) for (x, y) in zip(sorted(miners), sorted(mines))))
	print(ans)


import math as m

def dis(x, y):
	return m.sqrt(x ** 2 + y ** 2)
t = int(input())
for i in range(t):
	n = int(input())
	(y, x) = ([], [])
	for j in range(2 * n):
		_ = tuple(input().split())
		if _[0] == '0':
			y.append(abs(int(_[1])))
		else:
			x.append(abs(int(_[0])))
	x.sort()
	y.sort()
	print(sum([dis(x[i], y[i]) for i in range(n)]))


from sys import stdin, stdout
from collections import Counter, OrderedDict
import math
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
(t,) = mp()
for _ in range(t):
	(n,) = mp()
	x = []
	y = []
	for i in range(2 * n):
		(a, b) = mp()
		if a == 0:
			x += [abs(b)]
		else:
			y += [abs(a)]
	x.sort()
	y.sort()
	summ = 0.0
	for i in range(n):
		summ += (x[i] * x[i] + y[i] * y[i]) ** 0.5
	cout(str(summ) + '\n')


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
MOD = 10 ** 9 + 7

def solve():
	n = int(input())
	AB = []
	CD = []
	for _ in range(n * 2):
		(x, y) = map(int, input().split())
		if x == 0:
			AB.append(y * y)
		else:
			CD.append(x * x)
	AB.sort()
	CD.sort()
	res = sum((pow(ab + cd, 0.5) for (ab, cd) in zip(AB, CD)))
	print(res)
t = int(input())
for _ in range(t):
	solve()


import math

def solve(X, Y, n):
	X = sorted(X)
	Y = sorted(Y)
	minEnergySum = 0
	for i in range(n):
		minEnergySum += math.sqrt(X[i] * X[i] + Y[i] * Y[i])
	return minEnergySum
t = int(input())
for tc in range(t):
	n = int(input())
	Miners = []
	Mines = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			Miners.append(abs(y))
		else:
			Mines.append(abs(x))
	result = solve(Miners, Mines, n)
	print(result)


from math import sqrt
for _ in range(int(input())):
	(a, b) = ([], [])
	n = int(input())
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x != 0:
			a.append(abs(x))
		if y != 0:
			b.append(abs(y))
	a.sort()
	b.sort()
	energy = 0
	for i in range(n):
		r = a[i] * a[i] + b[i] * b[i]
		p = sqrt(r)
		energy += p
	print(energy)


import sys, io, os
try:
	Z = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	Z = lambda : sys.stdin.readline().encode()
O = []
for _ in range(int(Z())):
	n = int(Z())
	m = []
	d = []
	s = 0
	for i in range(2 * n):
		(x, y) = map(int, Z().split())
		if x:
			d.append(abs(x))
		else:
			m.append(abs(y))
	m.sort()
	d.sort()
	for i in range(n):
		s += (m.pop() ** 2 + d.pop() ** 2) ** 0.5
	O.append(str(s))
print('\n'.join(O))


import math

def solve(x, y):
	x.sort()
	y.sort()
	ans = 0
	for i in range(len(x)):
		ans += math.sqrt(1.0 * x[i] * x[i] + 1.0 * y[i] * y[i])
	return ans
t = int(input())
for _ in range(t):
	n = int(input()) * 2
	(xp, yp) = ([], [])
	for i in range(n):
		(x, y) = map(int, input().split())
		if x == 0:
			yp.append(abs(y))
		else:
			xp.append(abs(x))
	print(solve(xp, yp))


t = int(input())
for j in range(t):
	n = int(input())
	(a, b) = ([], [])
	for i in range(n * 2):
		nums = list(map(int, input().split()))
		if nums[0] == 0:
			a.append(abs(nums[1]))
		else:
			b.append(abs(nums[0]))
	a.sort()
	b.sort()
	g = 0
	for i in range(n):
		g = g + (a[i] ** 2 + b[i] ** 2) ** 0.5
	print(g)


for test in range(int(input())):
	n = int(input())
	(diamond, miner) = ([], [])
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miner.append(abs(y))
		else:
			diamond.append(abs(x))
	miner.sort()
	diamond.sort()
	dis = 0
	for (i, j) in zip(miner, diamond):
		dis += (i ** 2 + j ** 2) ** 0.5
	print(dis)


t = int(input())
while t:
	t -= 1
	n = int(input())
	mine = []
	miner = []
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			miner.append(abs(b))
		elif b == 0:
			mine.append(abs(a))
	mine.sort()
	miner.sort()
	c = 0
	for i in range(n):
		c += (mine[i] ** 2 + miner[i] ** 2) ** 0.5
	print(c)


import math

def main():
	t = int(input())
	diamond = []
	miner = []
	sum = 0
	sum_list = []
	for i in range(t):
		n = int(input())
		for j in range(2 * n):
			(x, y) = input().split()
			if int(x) == 0:
				miner.append(abs(int(y)))
			else:
				diamond.append(abs(int(x)))
		diamond = sorted(diamond)
		miner = sorted(miner)
		for j in range(n):
			sum += math.sqrt(diamond[j] * diamond[j] + miner[j] * miner[j])
		sum_list.append(sum)
		sum = 0
		diamond = []
		miner = []
	for i in range(t):
		print(sum_list[i])
main()


import os, sys, heapq as h, time
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import bisect_left, bisect_right
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def getInt():
	return int(input())

def getStrs():
	return input().split()

def getInts():
	return list(map(int, input().split()))

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = []
	B = []
	for i in range(2 * N):
		(x, y) = getInts()
		if not x:
			A.append(abs(y))
		if not y:
			B.append(abs(x))
	ans = 0
	A.sort()
	B.sort()
	for i in range(N):
		ans += math.sqrt(A[i] * A[i] + B[i] * B[i])
	return ans
	return
for _ in range(getInt()):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	miners = []
	diamonds = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miners.append(abs(y))
		else:
			diamonds.append(abs(x))
	miners.sort()
	diamonds.sort()
	answer = sum([(x ** 2 + y ** 2) ** 0.5 for (x, y) in zip(miners, diamonds)])
	print(answer)


import sys
Z = sys.stdin.readline
for _ in [0] * int(Z()):
	n = int(Z())
	m = []
	d = []
	s = 0
	for i in range(2 * n):
		(x, y) = map(int, Z().split())
		if x:
			d.append(abs(x))
		else:
			m.append(abs(y))
	m.sort()
	d.sort()
	for i in range(n):
		s += (m.pop() ** 2 + d.pop() ** 2) ** 0.5
	print(s)


for t in range(int(input())):
	miners = []
	diamon = []
	for n in range(2 * int(input())):
		coord = input().split(' ')
		if coord[0] == '0':
			miners.append(abs(int(coord[1])))
		elif coord[1] == '0':
			diamon.append(abs(int(coord[0])))
	miners.sort()
	diamon.sort()
	print(sum([(miners[n] ** 2 + diamon[n] ** 2) ** 0.5 for n in range(len(miners))]))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if not a:
			y.append(abs(b))
		else:
			x.append(abs(a))
	x.sort()
	y.sort()
	ans = 0
	for i in range(n):
		ans += (y[i] ** 2 + x[i] ** 2) ** 0.5
	print(ans)


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [X[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [X[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n):
		self.BIT = [0] * (n + 1)
		self.num = n

	def query(self, idx):
		res_sum = 0
		while idx > 0:
			res_sum += self.BIT[idx]
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		while idx <= self.num:
			self.BIT[idx] += x
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

		def __init__(self, val):
			self.left = None
			self.right = None
			self.max = val

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class Matrix:
	mod = 10 ** 9 + 7

	def set_mod(m):
		Matrix.mod = m

	def __init__(self, L):
		self.row = len(L)
		self.column = len(L[0])
		self._matrix = L
		for i in range(self.row):
			for j in range(self.column):
				self._matrix[i][j] %= Matrix.mod

	def __getitem__(self, item):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		return self._matrix[i][j]

	def __setitem__(self, item, val):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		self._matrix[i][j] = val

	def __add__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matrix[i][j] + other._matrix[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __sub__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matrix[i][j] - other._matrix[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __mul__(self, other):
		if type(other) != int:
			if self.column != other.row:
				raise SizeError('sizes of matrixes are different')
			res = [[0 for j in range(other.column)] for i in range(self.row)]
			for i in range(self.row):
				for j in range(other.column):
					temp = 0
					for k in range(self.column):
						temp += self._matrix[i][k] * other._matrix[k][j]
					res[i][j] = temp % Matrix.mod
			return Matrix(res)
		else:
			n = other
			res = [[n * self._matrix[i][j] % Matrix.mod for j in range(self.column)] for i in range(self.row)]
			return Matrix(res)

	def __pow__(self, m):
		if self.column != self.row:
			raise MatrixPowError('the size of row must be the same as that of column')
		n = self.row
		res = Matrix([[int(i == j) for i in range(n)] for j in range(n)])
		while m:
			if m % 2 == 1:
				res = res * self
			self = self * self
			m //= 2
		return res

	def __str__(self):
		res = []
		for i in range(self.row):
			for j in range(self.column):
				res.append(str(self._matrix[i][j]))
				res.append(' ')
			res.append('\n')
		res = res[:len(res) - 1]
		return ''.join(res)
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import log, gcd, sqrt
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
for _ in range(int(input())):
	n = int(input())
	res = 0
	X = []
	Y = []
	for i in range(2 * n):
		(x, y) = mi()
		if not x:
			Y.append(abs(y))
		else:
			X.append(abs(x))
	X.sort()
	Y.sort()
	for i in range(n):
		(x, y) = (X[i], Y[i])
		res += sqrt(x ** 2 + y ** 2)
	print(res)


def cost(x, y):
	return (x * x + y * y) ** 0.5
for _ in range(int(input())):
	n = int(input())
	miners = [None] * n
	mines = [None] * n
	i = j = 0
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miners[i] = abs(y)
			i += 1
		else:
			mines[j] = abs(x)
			j += 1
	energy = 0
	miners.sort()
	mines.sort()
	for i in range(n):
		energy += cost(mines[i], miners[i])
	print(energy)


from math import sqrt
for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			a += [abs(y)]
		else:
			b += [abs(x)]
	a.sort()
	b.sort()
	dist = 0
	for i in range(n):
		dist += sqrt(a[i] ** 2 + b[i] ** 2)
	print(dist)


import sys
inp = [int(x) for x in sys.stdin.read().split()]
ii = 0
out = []
t = inp[ii]
ii += 1

def distance(y1, x2):
	return ((-1 * x2) ** 2 + y1 ** 2) ** 0.5
for tc in range(t):
	miners = []
	diamonds = []
	n = inp[ii]
	ii += 1
	for pt in range(2 * n):
		x = inp[ii]
		ii += 1
		y = inp[ii]
		ii += 1
		if x == 0:
			miners.append(abs(y))
		elif y == 0:
			diamonds.append(abs(x))
	miners.sort(reverse=True)
	diamonds.sort(reverse=True)
	energy = 0
	for x in range(n):
		energy += distance(miners[x], diamonds[x])
	print(energy)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)

def read_values():
	return map(int, input().split())

def read_index():
	return map(lambda x: int(x) - 1, input().split())

def read_list():
	return list(read_values())

def read_lists(N):
	return [read_list() for n in range(N)]

def solve():
	N = int(input())
	M = []
	D = []
	for _ in range(2 * N):
		(m, d) = read_values()
		if m != 0:
			M.append(abs(m))
		if d != 0:
			D.append(abs(d))
	M.sort(reverse=True)
	D.sort(reverse=True)
	res = 0
	for (m, d) in zip(M, D):
		res += (m ** 2 + d ** 2) ** 0.5
	return res

def main():
	T = int(input())
	res = []
	for _ in range(T):
		res.append(str(solve()))
	for r in res:
		print(r)
main()


import math
for _ in range(int(input())):
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		z = list(map(int, input().split()))
		if z[0] == 0:
			x.append(abs(z[1]))
		else:
			y.append(abs(z[0]))
	x.sort()
	y.sort()
	z = 0
	for i in range(n):
		z += math.sqrt(x.pop() ** 2 + y.pop() ** 2)
	print(z)


import math
t = int(input())
for hh in range(0, t):
	n = int(input())
	a = []
	b = []
	for i in range(0, 2 * n):
		(x, y) = [int(x) for x in input().split()]
		if x == 0:
			a.append(y * y)
		else:
			b.append(x * x)
	a.sort()
	b.sort()
	ans = 0
	for i in range(0, n):
		ans += math.sqrt(a[i] + b[i])
	print('{0:.10f}'.format(ans))


import math
t = int(input())
for _ in range(t):
	x = []
	y = []
	n = int(input())
	for __ in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			if b < 0:
				y.append(-1 * b)
			else:
				y.append(b)
		elif a < 0:
			x.append(-1 * a)
		else:
			x.append(a)
	x.sort()
	y.sort()
	sum = 0
	for i in range(n):
		sum += math.pow(x[i] * x[i] + y[i] * y[i], 0.5)
	print(sum)


t = int(input())
while t:
	n = int(input())
	miners = []
	diamond = []
	for i in range(2 * n):
		(x, y) = input().split()
		if int(x) == 0:
			miners.append(int(y) ** 2)
		else:
			diamond.append(int(x) ** 2)
	miners.sort()
	diamond.sort()
	ans = [(miners[i] + diamond[i]) ** 0.5 for i in range(n)]
	print(sum(ans))
	t -= 1


import math
for _ in range(int(input())):
	n = int(input())
	xar = []
	yar = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			if y > 0:
				yar.append(y)
			else:
				yar.append(-1 * y)
		if y == 0:
			if x > 0:
				xar.append(x)
			else:
				xar.append(-1 * x)
	xar.sort()
	yar.sort()
	sum = 0
	for i in range(n):
		sum += math.sqrt(xar[i] * xar[i] + yar[i] * yar[i])
	print(sum)


from math import sqrt
for _ in range(int(input())):
	n = int(input())
	(miners, mines) = ([], [])
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if not x:
			miners.append(y)
		else:
			mines.append(x)
	miners.sort(key=lambda n: abs(n))
	mines.sort(key=lambda n: abs(n))
	print(sum((sqrt(miners[i] * miners[i] + mines[i] * mines[i]) for i in range(n))))


from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
from math import hypot
(t,) = rl()
for _ in range(t):
	(n,) = rl()
	miners = []
	diamonds = []
	for _ in range(2 * n):
		(x, y) = rl()
		if x == 0:
			miners.append(abs(y))
		else:
			diamonds.append(abs(x))
	miners.sort()
	diamonds.sort()
	print(sum((hypot(x, y) for (x, y) in zip(diamonds, miners))))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b) = ([], [])
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			a.append(abs(y))
		else:
			b.append(abs(x))
	a.sort()
	b.sort()
	res = 0
	for i in range(n):
		res += math.sqrt(a[i] ** 2 + b[i] ** 2)
	print(res)


import math

def dis(x, y):
	return math.sqrt(x ** 2 + y ** 2)

def main():
	T = int(input())
	while T:
		T -= 1
		lx = []
		ly = []
		n = int(input())
		for i in range(n * 2):
			s = input().split()
			a = int(s[0])
			b = int(s[1])
			if a:
				lx.append(abs(a))
			else:
				ly.append(abs(b))
		lx.sort()
		ly.sort()
		lx = lx[::-1]
		ly = ly[::-1]
		ans = 0
		for i in range(len(lx)):
			ans += dis(lx[i], ly[i])
		print(ans)
main()


from sys import stdin
from math import sqrt
for t in range(int(input())):
	n = int(input())
	miners = []
	diamonds = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miners.append(y * y)
		else:
			diamonds.append(x * x)
	miners.sort()
	diamonds.sort(reverse=0)
	summ = 0
	for i in range(n):
		summ += sqrt(miners[i] + diamonds[i])
	print(summ)


from math import sqrt

def dist(a, b):
	return sqrt(a ** 2 + b ** 2)

def solve():
	n = int(input())
	d = []
	m = []
	for p in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			m.append(abs(b))
		else:
			d.append(abs(a))
	d.sort()
	m.sort()
	ans = 0
	for x in range(n):
		ans += dist(d[x], m[x])
	print(ans)
for _ in range(int(input())):
	solve()


import sys
import math
r = sys.stdin.readline
t = int(r())
for tests in range(t):
	n = int(r())
	xarr = []
	yarr = []
	summ = 0
	for i in range(n * 2):
		(x, y) = map(int, r().split())
		if x:
			xarr.append(abs(x))
		else:
			yarr.append(abs(y))
	xarr.sort()
	yarr.sort()
	for i in range(-n, 0):
		summ += math.hypot(xarr[i], yarr[i])
	print(summ)


import math
for i in range(int(input())):
	n = int(input())
	miner = []
	ans = 0
	diamond = []
	for j in range(2 * n):
		xy = list(map(int, input().rsplit()))
		if xy[0] == 0:
			miner.append(abs(xy[1]))
		elif xy[1] == 0:
			diamond.append(abs(xy[0]))
		else:
			print('invalid input')
			break
	miner.sort()
	diamond.sort()
	for j in range(n):
		ans += math.sqrt(miner[j] ** 2 + diamond[j] ** 2)
	print(ans)


import os, sys, time, collections, math, pprint, itertools as it, operator as op, bisect as bs, functools as fn
(maxx, localsys, mod) = (float('inf'), 0, int(1000000000.0 + 7))
nCr = lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)
ceil = lambda n, x: (n + x - 1) // x
(osi, oso) = ('/home/priyanshu/Documents/cp/input.txt', '/home/priyanshu/Documents/cp/output.txt')
if os.path.exists(osi):
	sys.stdin = open(osi, 'r')
	sys.stdout = open(oso, 'w')
input = sys.stdin.readline

def maps():
	return map(int, input().split())

def rel(a, b):
	return abs(a - b) / max(1, abs(b))
for _ in range(int(input())):
	(x, y) = ([], [])
	n = int(input())
	for i in range(2 * n):
		(u, v) = maps()
		if u == 0:
			y.append(v)
		else:
			x.append(u)
	x.sort(key=abs)
	y.sort(key=abs)
	(ans1, ans2, ans3) = (0, 0, 0)
	for i in range(n):
		ans3 += math.sqrt(y[i] * y[i] + x[i] * x[i])
	print(ans3)


t = int(input())
for _ in range(t):
	n = int(input())
	xax = []
	yax = []
	for _ in range(2 * n):
		(h, k) = map(int, input().strip().split(' '))
		if h == 0:
			yax.append(k)
		else:
			xax.append(h)
	xax = [abs(x) ** 2 for x in xax]
	yax = [abs(y) ** 2 for y in yax]
	xax.sort()
	yax.sort()
	lst = sum([(xax[i] + yax[i]) ** 0.5 for i in range(n)])
	print(lst)


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby
for _ in range(II()):
	n = II()
	x = []
	y = []
	for i in range(2 * n):
		(x1, y1) = LI()
		if x1 == 0:
			y.append(abs(y1))
		else:
			x.append(abs(x1))
	x.sort()
	y.sort()
	ans = 0
	for i in range(n):
		ans += math.sqrt(x[i] ** 2 + y[i] ** 2)
	print(ans)


from math import hypot
t = int(input())
for _ in range(t):
	n = int(input())
	miner = []
	dia = []
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miner.append(abs(y))
		else:
			dia.append(abs(x))
	res1 = 0
	miner.sort()
	dia.sort()
	for (a, b) in zip(miner, dia):
		res1 += hypot(a, b)
	res2 = 0
	dia.reverse()
	for (a, b) in zip(miner, dia):
		res2 += hypot(a, b)
	print(f'{min(res1, res2)}')


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	(n,) = R()
	a = ([], [])
	for _ in [0] * n * 2:
		for (x, y) in zip(a, R()):
			x += ([abs(y)], [])[y == 0]
	print(sum(((x * x + y * y) ** 0.5 for (x, y) in zip(*map(sorted, a)))))


for _ in range(int(input())):
	(n, m, d) = (int(input()), [], [])
	for _ in range(n + n):
		(x, y) = map(int, input().split())
		if x == 0:
			m.append(abs(y))
		else:
			d.append(abs(x))
	m.sort()
	d.sort()
	ans = 0
	for i in range(n):
		ans += (m[i] * m[i] + d[i] * d[i]) ** 0.5
	print(ans)


import sys
input = sys.stdin.readline
from collections import *
for _ in range(int(input())):
	n = int(input())
	xs = []
	ys = []
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if y == 0:
			xs.append(x ** 2)
		else:
			ys.append(y ** 2)
	xs.sort()
	ys.sort()
	ans = 0
	for (x, y) in zip(xs, ys):
		ans += (x + y) ** 0.5
	print(ans)


i = 0
t = int(input())
while i < t:
	hipotenusa = 0.0
	(minerador, mina) = ([], [])
	n = int(input())
	for j in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			minerador.append(abs(b))
		if b == 0:
			mina.append(abs(a))
	minerador.sort()
	mina.sort()
	for s in range(n):
		hipotenusa += (minerador[s] ** 2 + mina[s] ** 2) ** 0.5
	print(hipotenusa)
	i += 1


for _ in range(int(input())):
	(miners, mines) = ([], [])
	for _ in range(int(input()) * 2):
		(x, y) = map(int, input().split())
		if x == 0:
			miners.append(abs(y))
		else:
			mines.append(abs(x))
	ans = sum(((x * x + y * y) ** 0.5 for (x, y) in zip(sorted(miners), sorted(mines))))
	print(ans)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	miners = []
	mines = []
	for _ in range(2 * n):
		(a, b) = map(int, stdin.readline().split())
		if a == 0:
			miners.append(b)
		else:
			mines.append(a)
	miners.sort(key=abs)
	mines.sort(key=abs)
	a1 = sum(((miners[i] ** 2 + mines[i] ** 2) ** 0.5 for i in range(n)))
	miners.sort(reverse=True)
	a2 = sum(((miners[i] ** 2 + mines[i] ** 2) ** 0.5 for i in range(n)))
	print(min(a1, a2))


import sys
import math
r = sys.stdin.readline
t = int(r())
for tests in range(t):
	n = int(r())
	xarr = []
	yarr = []
	summ = 0
	for i in range(n * 2):
		(x, y) = map(int, r().split())
		xarr.append(x ** 2)
		yarr.append(y ** 2)
	xarr.sort()
	yarr.sort()
	for i in range(-n, 0):
		summ += math.sqrt(xarr[i] + yarr[i])
	print(summ)


for _ in range(int(input())):
	n = int(input())
	X = []
	Y = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if y == 0:
			X.append(abs(x))
		elif x == 0:
			Y.append(abs(y))
	X.sort()
	Y.sort()
	ans = 0
	for i in range(n):
		ans += (X[i] * X[i] + Y[i] * Y[i]) ** 0.5
	print(ans)


for _ in range(int(input())):
	n = int(input())
	xx = []
	yy = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if y == 0:
			xx.append(abs(x))
		else:
			yy.append(abs(y))
	xx.sort()
	yy.sort()
	summ = 0
	for i in range(n):
		summ += (xx[i] ** 2 + yy[i] ** 2) ** 0.5
	print(summ)


import sys
for _ in range(int(input())):
	n = int(input())
	(miner, dia) = ([], [])
	f = lambda i: (i[0] * i[0] + i[1] * i[1]) ** 0.5
	for _ in range(2 * n):
		(x, y) = map(int, sys.stdin.readline().split())
		if x:
			dia.append(abs(x))
		else:
			miner.append(abs(y))
	print(sum(map(f, zip(sorted(miner), sorted(dia)))))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7
for _ in range(II()):
	n = II()
	(xx, yy) = ([], [])
	for _ in range(n * 2):
		(x, y) = MI()
		if y == 0:
			xx.append(abs(x))
		else:
			yy.append(abs(y))
	ans = 0
	xx.sort()
	yy.sort()
	for (x, y) in zip(xx, yy):
		ans += (x ** 2 + y ** 2) ** 0.5
	print(ans)


from math import sqrt

def solve():
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		(x_temp, y_temp) = input().split()
		x_temp = abs(int(x_temp))
		y_temp = abs(int(y_temp))
		if y_temp == 0:
			x.append(x_temp)
		else:
			y.append(y_temp)
	x = sorted(x)
	y = sorted(y)
	ans = 0
	for i in range(len(x)):
		ans += sqrt(x[i] ** 2 + y[i] ** 2)
	print(ans)
	return 0
t = int(input())
while t:
	solve()
	t -= 1


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	mines = []
	miners = []
	for _ in range(2 * n):
		coords = [int(x) for x in input().split()]
		if coords[1]:
			mines.append(abs(coords[1]))
		else:
			miners.append(abs(coords[0]))
	miners.sort()
	mines.sort()
	total = 0
	for i in range(n):
		total += (miners[i] * miners[i] + mines[i] * mines[i]) ** (1 / 2)
	print(total)


import math
t = int(input())
for i in range(t):
	n = int(input())
	miners = []
	diamonds = []
	summary = 0
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miners.append((0, abs(y)))
		else:
			diamonds.append((abs(x), 0))
	miners.sort()
	diamonds.sort()
	for i in range(n):
		miner = miners[i]
		diamond = diamonds[i]
		summary += math.sqrt(miner[1] ** 2 + diamond[0] ** 2)
	print(summary)


import sys
input = sys.stdin.readline
import math
import copy
from decimal import Decimal
t = int(input())
for _ in range(t):
	n = int(input())
	diamond = []
	miner = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miner.append(abs(y))
		else:
			diamond.append(abs(x))
	temp = []
	diamond.sort()
	miner.sort()
	for i in range(n):
		temp.append(miner[i] ** 2 + diamond[i] ** 2)
	ans = 0
	for i in temp:
		ans += i ** 0.5
	print(ans)


import os, io, math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	diam = []
	mines = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			diam.append(abs(y))
		else:
			mines.append(abs(x))
	diam.sort()
	mines.sort()
	ans = 0
	for i in range(n):
		ans += math.sqrt(diam[i] * diam[i] + mines[i] * mines[i])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [[], []]
	for i in range(2 * n):
		(l, r) = map(int, input().split())
		if l:
			a[0].append(abs(l))
		else:
			a[1].append(abs(r))
	print(sum(((a * a + b * b) ** 0.5 for (a, b) in zip(*map(sorted, a)))))


t = int(input())
while t:
	n = int(input())
	m = []
	d = []
	ans = 0
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			m.append(abs(y))
		else:
			d.append(abs(x))
	m.sort()
	d.sort()
	for i in range(n):
		ans += (m[i] * m[i] + d[i] * d[i]) ** 0.5
	print(ans)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if y == 0:
			a.append(abs(x))
		else:
			b.append(abs(y))
	a.sort()
	b.sort()
	res = 0
	j = 0
	for i in range(len(a)):
		if j >= len(b):
			break
		res += (a[i] ** 2 + b[j] ** 2) ** (1 / 2)
		j += 1
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	m = []
	d = []
	for _ in range(2 * n):
		(x, y) = input().split()
		if x == '0':
			d.append(abs(int(y)))
		else:
			m.append(abs(int(x)))
	s = 0
	d.sort()
	m.sort()
	for i in range(n):
		s += pow(m[i] * m[i] + d[i] * d[i], 0.5)
	print(s)


import math
N = int(input())
for _ in range(N):
	n = int(input())
	miners = []
	mines = []
	for i in range(2 * n):
		(k1, k2) = input().split()
		if k1 == '0':
			miners.append(abs(int(k2)))
		else:
			mines.append(abs(int(k1)))
	miners = sorted(miners, reverse=False)
	mines = sorted(mines, reverse=False)
	d = 0
	for (m1, m2) in zip(miners, mines):
		d += math.sqrt(m1 ** 2 + m2 ** 2)
	print(d)


def DiamondMiner():
	n = int(input())
	(mine, miner) = ([None] * n, [None] * n)
	(p, q, sum) = (0, 0, 0)
	for i in range(2 * n):
		xy = list(map(int, input().strip().split()))
		(x, y) = (xy[0], xy[1])
		if x == 0:
			miner[p] = abs(y)
			p += 1
		else:
			mine[q] = abs(x)
			q += 1
	mine.sort()
	miner.sort()
	for i in range(n):
		sum += (mine[i] ** 2 + miner[i] ** 2) ** (1 / 2)
	print(sum)
t = int(input())
for i in range(t):
	DiamondMiner()


import sys
import math
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(input())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def main():
	for t in range(get_int()):
		miners = []
		mines = []
		n = int(input())
		for i in range(0, 2 * n):
			(x, y) = get_ints_in_variables()
			if x == 0:
				miners.append(abs(y))
			if y == 0:
				mines.append(abs(x))
		miners.sort()
		mines.sort()
		res = 0
		for i in range(0, n):
			op = miners[i] * miners[i] * 1.0 + mines[i] * mines[i] * 1.0
			srt = math.sqrt(op)
			res += srt
		print(res)
main()


from math import sqrt
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	mi = []
	m = []
	for i in range(n * 2):
		(a, b) = list(map(int, input().split()))
		if a == 0:
			mi.append(abs(b))
		else:
			m.append(abs(a))
	mi.sort()
	m.sort()
	total = 0
	for i in range(0, n):
		total += sqrt(m[i] * m[i] + mi[i] * mi[i])
	print(total)


for _ in range(int(input())):
	x = []
	y = []
	n = int(input())
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			y.append(abs(b))
		else:
			x.append(abs(a))
	ans = 0
	x = sorted(x)
	y = sorted(y)
	for i in range(n):
		ans += (x[i] * x[i] + y[i] * y[i]) ** 0.5
	print('%.10f' % ans)


import math
import sys
Z = sys.stdin.readline
for _ in range(int(Z())):
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		(a, b) = map(int, Z().split())
		if b == 0:
			x.append(abs(a))
		else:
			y.append(abs(b))
	x.sort()
	y.sort()
	dist = 0
	for i in range(n):
		dist += math.sqrt(x[i] * x[i] + y[i] * y[i])
	print(dist)


import math
t = int(input())
while t:
	t -= 1
	n = int(input())
	n <<= 1
	a = []
	b = []
	while n:
		n -= 1
		(i, j) = map(int, input().split())
		if i:
			a.append(abs(i))
		else:
			b.append(abs(j))
	a.sort()
	b.sort()
	ans = 0
	for i in range(0, len(a)):
		ans += math.sqrt(a[i] * a[i] + b[i] * b[i])
	print(ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	lx = []
	ly = []
	for j in range(2 * n):
		(x, y) = map(int, input().strip().split(' '))
		if x == 0:
			ly.append(abs(y))
		else:
			lx.append(abs(x))
	lx.sort()
	ly.sort()
	s = 0
	for j in range(n):
		s += math.sqrt(lx[j] ** 2 + ly[j] ** 2)
	print(s)


from math import sqrt
import sys
inp = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	miner = []
	diamonds = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miner.append(abs(y))
		else:
			diamonds.append(abs(x))
	miner.sort()
	diamonds.sort()
	res = 0
	for i in range(n):
		res += sqrt(diamonds[i] ** 2 + miner[i] ** 2)
	print(res)


import math
for _ in range(int(input())):
	n = int(input())
	x = []
	y = []
	for _ in range(2 * n):
		(a, b) = tuple(map(int, input().split()))
		if a == 0:
			y += [abs(b)]
		elif b == 0:
			x += [abs(a)]
	x.sort()
	y.sort()
	k = 0
	for i in range(n):
		k += math.sqrt(x[i] ** 2 + y[i] ** 2)
	print(k)


import math

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		miners = []
		mines = []
		for _ in range(2 * n):
			point = list(map(int, input().split()))
			if point[0] == 0:
				miners.append(point)
			else:
				mines.append(point)
		miners.sort(key=lambda x: abs(x[1]))
		mines.sort(key=lambda x: abs(x[0]))
		min_energy = 0
		for i in range(n):
			min_energy += math.sqrt(miners[i][1] * miners[i][1] + mines[i][0] * mines[i][0])
		print(min_energy)
main()


import math
T = int(input())
for cas in range(T):
	ans = 0
	x = []
	y = []
	n = int(input())
	for i in range(2 * n):
		(tx, ty) = map(int, input().split())
		if tx == 0:
			if ty > 0:
				y.append(ty)
			else:
				y.append(-ty)
		elif tx > 0:
			x.append(tx)
		else:
			x.append(-tx)
	x.sort()
	y.sort()
	for i in range(n):
		ans += math.sqrt(x[i] * x[i] + y[i] * y[i])
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		x = []
		y = []
		for i in range(2 * n):
			(a, b) = map(int, input().split())
			if a == 0:
				x.append(abs(b))
			else:
				y.append(abs(a))
		x.sort()
		y.sort()
		ans = 0
		from math import sqrt
		for i in range(n):
			ans += sqrt(x[i] * x[i] + y[i] * y[i])
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import math
MOD = 1000000007
for _ in range(int(input())):
	n = int(input())
	(a, b) = (list(), list())
	for _ in range(2 * n):
		(x, y) = map(int, input().split(' '))
		if x == 0:
			b.append(abs(y))
		else:
			a.append(abs(x))
	a.sort()
	b.sort()
	ans = 0
	for i in range(n):
		x = a[i] * a[i] + b[i] * b[i]
		ans += math.sqrt(x)
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	(miners, mines) = ([], [])
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x:
			mines.append(abs(x))
		else:
			miners.append(abs(y))
	miners.sort(reverse=True)
	mines.sort(reverse=True)
	res = 0
	for (x, y) in zip(miners, mines):
		res += (x * x + y * y) ** (1 / 2)
	print(res)


import sys
input = sys.stdin.readline
import math

def solution(n, points):
	xs = [p[0] for p in points if p[1] == 0]
	ys = [p[1] for p in points if p[0] == 0]
	xs.sort(key=lambda x: abs(x))
	ys.sort(key=lambda y: abs(y))
	print(sum([math.sqrt(x ** 2 + y ** 2) for (x, y) in zip(xs, ys)]))
T = int(input())
for t in range(T):
	n = int(input())
	points = [list(map(int, input().split())) for _ in range(2 * n)]
	solution(n, points)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	l1 = []
	l2 = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			l1.append(abs(y))
		if y == 0:
			l2.append(abs(x))
	l1.sort()
	l2.sort()
	ans = 0
	for i in range(n):
		ans += math.sqrt(l1[i] * l1[i] + l2[i] * l2[i])
	print(ans)


import math

def solve(m, d, bound):
	m.sort()
	d.sort()
	ans = 0
	res = 0
	for i in range(0, bound):
		res = math.sqrt(m[i] * m[i] + d[i] * d[i])
		ans = ans + res
	return ans
t = int(input())
while t > 0:
	n = int(input())
	points = 2 * n
	m = []
	d = []
	while points > 0:
		(x, y) = map(int, input().split())
		if x == 0:
			m.append(abs(y))
		if y == 0:
			d.append(abs(x))
		points = points - 1
	print(solve(m, d, len(m)))
	t = t - 1


import math
test_case = int(input())
for i in range(test_case):
	n = int(input())
	miner_pos = []
	dimond_pos = []
	for i in range(2 * n):
		(r, c) = map(int, input().split())
		if r == 0:
			miner_pos.append(c * c)
		else:
			dimond_pos.append(r * r)
	min_sum = 0
	miner_pos.sort()
	dimond_pos.sort()
	for i in range(n):
		min_sum = min_sum + math.sqrt(miner_pos[i] + dimond_pos[i])
	print(min_sum)


from math import sqrt
t = int(input())
for _ in range(t):
	n = int(input())
	(miners, mines) = ([], [])
	for _ in range(2 * n):
		(x, y) = (int(x) for x in input().split())
		if x:
			mines.append(abs(x))
		else:
			miners.append(abs(y))
	(mines.sort(), miners.sort())
	print(sum((sqrt(mines[i] ** 2 + miners[i] ** 2) for i in range(n))))


import math
I = lambda : map(int, input().split())
for _ in [0] * int(input()):
	n = int(input())
	m = [0] * n
	i = 0
	d = [0] * n
	j = 0
	for _ in [0] * (2 * n):
		(x, y) = I()
		if x == 0:
			m[i] = y ** 2
			i = i + 1
		else:
			d[j] = x ** 2
			j = j + 1
	m.sort()
	d.sort()
	s = 0
	for (b, v) in zip(m, d):
		s = s + math.sqrt(b + v)
	print(s)


import sys
input = sys.stdin.readline

def qsort(A, left, right):
	while left < right:
		q = partition(A, left, right)
		if q - 1 - left < right - (q + 1):
			qsort(A, left, q - 1)
			left = q + 1
		else:
			qsort(A, q + 1, right)
			right = q - 1

def partition(A, left, right):
	q = A[right]
	i = left - 1
	for j in range(left, right):
		if abs(A[j]) < abs(q):
			i += 1
			(A[i], A[j]) = (A[j], A[i])
	(A[i + 1], A[right]) = (A[right], A[i + 1])
	return i + 1

def solve(miners, mines, n):
	qsort(miners, 0, n - 1)
	qsort(mines, 0, n - 1)
	total = 0
	for i in range(n):
		total += distance(miners[i], mines[i])
	print(total)

def distance(miner, mine):
	return (miner * miner + mine * mine) ** (1 / 2)
t = int(input())
for _ in range(t):
	n = int(input())
	mines = []
	miners = []
	for _ in range(2 * n):
		coords = [int(x) for x in input().split()]
		if coords[0] == 0:
			mines.append(abs(coords[1]))
		else:
			miners.append(abs(coords[0]))
	solve(miners, mines, n)


import sys
import math
from math import factorial, inf, gcd, pi, sqrt
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
sys.setrecursionlimit(10 ** 5)
t = 1
t = int(input())
for ii in range(t):
	n = int(input())
	x = []
	y = []
	for j in range(2 * n):
		(a, b) = (int(i) for i in input().split())
		if b == 0:
			x.append(a)
		elif a == 0:
			y.append(b)
	x.sort(key=lambda k: abs(k))
	y.sort(key=lambda k: abs(k))
	ans = 0
	for (i, j) in zip(x, y):
		ans += sqrt(i * i + j * j)
	print(ans)


def fun():
	from math import sqrt
	for _ in range(int(input())):
		n = int(input())
		(miner, diamond) = ([], [])
		for i in range(2 * n):
			(x, y) = map(int, input().split())
			if x == 0:
				miner.append(abs(y))
			if y == 0:
				diamond.append(abs(x))
		miner.sort()
		diamond.sort()
		sum1 = 0
		for i in range(n):
			sum1 += sqrt(diamond[i] * diamond[i] + miner[i] * miner[i])
		print(sum1)
fun()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	diamonds = []
	minners = []
	for _ in range(2 * n):
		(x, y) = list(map(int, input().split()))
		if x == 0:
			minners.append(abs(y))
		else:
			diamonds.append(abs(x))
	minners.sort(reverse=True)
	diamonds.sort(reverse=True)
	ans = 0
	for (x, y) in zip(minners, diamonds):
		ans += math.sqrt(x * x + y * y)
	print(ans)


import math

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	(a, b) = ([], [])
	for (x, y) in (map(int, input().split()) for _ in range(n * 2)):
		if x:
			a.append(abs(x))
		else:
			b.append(abs(y))
	s = sum((math.sqrt(x * x + y * y) for (x, y) in zip(sorted(a), sorted(b))))
	print(s)


import math

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		miners = [-1] * n
		mines = [-1] * n
		(i, j) = (0, 0)
		for _ in range(2 * n):
			(a, b) = map(lambda x: abs(int(x)), input().split())
			if a == 0:
				miners[i] = b
				i += 1
			else:
				mines[j] = a
				j += 1
		mines.sort()
		miners.sort()
		acc = 0
		for i in range(n):
			acc += math.sqrt(miners[i] ** 2 + mines[i] ** 2)
		print(f'{acc:.15f}')
main()


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_(mrr):
	xx = sorted([abs(x) for (x, y) in mrr if y == 0])
	yy = sorted([abs(y) for (x, y) in mrr if x == 0])
	res3 = 0
	for (a, b) in zip(xx, yy):
		res3 += (a ** 2 + b ** 2) ** 0.5
	return res3
for case_num in range(int(input())):
	k = int(input())
	mrr = read_matrix(2 * k)
	res = solve(mrr)
	print(res)


from math import sqrt
for _ in range(int(input())):
	n = int(input())
	sh = []
	al = []
	for i in range(n * 2):
		(x, y) = list(map(int, input().split()))
		if x == 0:
			sh.append(abs(y))
		else:
			al.append(abs(x))
	sh.sort()
	al.sort()
	ans = 0
	for i in range(n):
		ans += sqrt(sh[i] ** 2 + al[i] ** 2)
	print(ans)


R = lambda : map(int, input().split())
(t,) = R()
exec(t * 'n,=R();a=[[],[]]\nfor _ in a*n:p=*R(),;i=p[0]==0;a[i]+=abs(p[i]),\nprint(sum((x*x+y*y)**.5for x,y in zip(*map(sorted,a))))\n')


from math import pi

def main():
	n = int(input())
	sh = []
	al = []
	for i in range(2 * n):
		(x, y) = [int(i) for i in input().split()]
		if x == 0:
			if y < 0:
				sh.append(-y)
			else:
				sh.append(y)
		elif x < 0:
			al.append(-x)
		else:
			al.append(x)
	sh.sort()
	al.sort()
	s = 0
	for i in range(n):
		s += (sh[i] ** 2 + al[i] ** 2) ** 0.5
	print(s)
for t in range(int(input())):
	main()


import math

def ass(a, b):
	print(f'Assertion error: {a} != {b}' if a != b else 'OK')

def nr():
	return nrs()[0]

def nrs():
	return [int(item) for item in input().split()]

def word():
	return input()

def words():
	return [item for item in input().split()]

def dump(lst):
	for (i, item) in enumerate(lst):
		print(i, item)

def binsearch(arr, a, b):
	m = (a + b) // 2
	if a >= b:
		return a - 1 if arr[a] == 0 else a
	return binsearch(arr, a, m - 1) if arr[m] == 0 else binsearch(arr, m + 1, b)

def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def f(n, miners, mines):
	res = 0
	for i in range(n):
		x = miners[i]
		y = mines[i]
		res += math.sqrt(x * x + y * y)
	return res
for i in range(nr()):
	n = nr()
	res = 0
	miners = []
	mines = []
	for i in range(2 * n):
		(x, y) = nrs()
		if x == 0:
			miners.append(abs(y))
		if y == 0:
			mines.append(abs(x))
	miners.sort()
	mines.sort()
	print(f(n, miners, mines))


def distance(v1, v2):
	return ((v1[0] - v2[0]) ** 2 + (v1[1] - v2[1]) ** 2) ** 0.5

def main():
	t = int(input())
	for c in range(t):
		n = int(input())
		miners = []
		diamonds = []
		for _ in range(2 * n):
			inp = input().rstrip().split(' ')
			if inp[0] == '0':
				miners.append((0, abs(int(inp[1]))))
			else:
				diamonds.append((abs(int(inp[0])), 0))
		miners.sort()
		diamonds.sort()
		res = 0.0
		while len(diamonds) > 0:
			res += distance(miners.pop(), diamonds.pop())
		print(res)
main()


import math
t = int(input())

def findmin(arr1):
	aa = set(arr1)
	arr = [i for i in aa]
	arr.sort()
	i = 0
	while i < len(arr):
		if i != arr[i]:
			return i
		i += 1
	return i
while t:
	t -= 1
	n = int(input())
	mm = []
	m = []
	n = 2 * n
	while n:
		n -= 1
		(a, b) = input().split()
		(a, b) = (int(a), int(b))
		if a == 0:
			mm.append(abs(b))
		else:
			m.append(abs(a))
	mm.sort()
	m.sort()
	mm = [i * i for i in mm]
	m = [i * i for i in m]
	ans = 0
	for i in range(len(mm)):
		ans += math.sqrt(mm[i] + m[i])
	print(ans)


import math
import sys
import collections
import bisect
import string
import time

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	n = int(input())
	m1 = []
	m2 = []
	for j in range(2 * n):
		(x, y) = get_ints()
		if x == 0:
			m2.append(abs(y))
		if y == 0:
			m1.append(abs(x))
	m1.sort()
	m2.sort()
	gb_ans = 0
	for j in range(n):
		v1 = m1[j] ** 2
		v2 = m2[j] ** 2
		sol = v1 + v2
		sol = math.sqrt(sol)
		gb_ans += sol
	print(gb_ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	p = []
	q = []
	for i in range(n * 2):
		(x, y) = map(int, input().split())
		if x == 0:
			q.append(abs(y))
		else:
			p.append(abs(x))
	p.sort()
	q.sort()
	ans = 0
	for i in range(n):
		ans += (p[i] * p[i] + q[i] * q[i]) ** 0.5
	print(ans)


from math import sqrt

def function(n, miners, mines):
	miners.sort()
	mines.sort()
	energy = 0
	for x in range(n):
		energy += sqrt(mines[x] ** 2 + miners[x] ** 2)
	print(energy)
t = int(input())
func = lambda x: abs(int(x))
for _ in range(t):
	n = int(input())
	mines = []
	miners = []
	for _ in range(2 * n):
		(a, b) = map(func, input().strip().split())
		if a:
			mines.append(a)
		elif b:
			miners.append(b)
	function(n, miners, mines)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	xs = []
	ys = []
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if x:
			xs.append(abs(x))
		if y:
			ys.append(abs(y))
	xs.sort()
	ys.sort()
	res = 0.0
	for i in range(n):
		res += (xs[i] ** 2 + ys[i] ** 2) ** 0.5
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	b = []
	for _ in range(n * 2):
		(x, y) = list(map(int, input().split()))
		if x == 0:
			b.append(y * y)
		else:
			a.append(x * x)
	a.sort()
	b.sort()
	d = 0
	for i in range(n):
		d = d + (a[i] + b[i]) ** 0.5
	print(d)


import math
import heapq
test_case = int(input())
for i in range(test_case):
	n = int(input())
	miner_pos = []
	dimond_pos = []
	for i in range(2 * n):
		(r, c) = map(int, input().split())
		if r == 0:
			heapq.heappush(miner_pos, c * c)
		else:
			heapq.heappush(dimond_pos, r * r)
	min_sum = 0
	for i in range(n):
		min_sum = min_sum + math.sqrt(heapq.heappop(miner_pos) + heapq.heappop(dimond_pos))
	print(min_sum)


for _ in range(int(input())):
	m = []
	n = []
	for __ in range(int(input()) * 2):
		(x, y) = map(int, input().split())
		if x == 0:
			n.append(abs(y))
		else:
			m.append(abs(x))
	print(sum(((i * i + j * j) ** 0.5 for (i, j) in zip(sorted(m), sorted(n)))))


import sys

def solve(ds, ms, n):
	ds = sorted([[abs(i), 0] for (i, _) in ds])
	ms = sorted([[0, abs(j)] for (_, j) in ms])
	res = 0
	for i in range(n):
		(di, dj) = ds[i]
		(mi, mj) = ms[i]
		res += ((di - mi) ** 2 + (dj - mj) ** 2) ** 0.5
	return res
t = int(sys.stdin.readline().strip())
ans = 0
for _ in range(t):
	n = int(sys.stdin.readline().strip())
	diamonds = []
	miners = []
	for k in range(2 * n):
		line = sys.stdin.readline().strip()
		(i, j) = list(map(int, line.split()))
		if i == 0:
			miners.append([i, j])
		else:
			diamonds.append([i, j])
	print(solve(diamonds, miners, n))


I = lambda : [*map(int, input().split())]
for _ in ' ' * I()[0]:
	(n,) = I()
	m = []
	d = []
	for i in range(2 * n):
		(a, b) = I()
		if a == 0:
			m += [abs(b)]
		else:
			d += [abs(a)]
	m.sort()
	d.sort()
	s = 0
	print(sum(((x * x + y * y) ** 0.5 for (x, y) in zip(m, d))))


import sys
import math
t = int(input())
for tt in range(t):
	n = int(input())
	miner = []
	diamond = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miner.append(abs(y))
		else:
			diamond.append(abs(x))
	miner.sort()
	diamond.sort()
	dist = 0
	for i in range(n):
		dist += math.sqrt(math.pow(diamond[i], 2) + math.pow(miner[i], 2))
	print(dist)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	miner = []
	mine = []
	for _ in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			miner.append(b)
		else:
			mine.append(a)
	miner.sort(key=lambda x: abs(x))
	mine.sort(key=lambda x: abs(x))
	ans = 0
	for i in range(n):
		ans += (miner[i] ** 2 + mine[i] ** 2) ** 0.5
	return ans
for _ in range(int(input())):
	print(solve())


import sys
from collections import deque, defaultdict
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians, ceil, floor, log, sqrt, ceil, floor, pi, hypot
from string import ascii_lowercase
from decimal import Decimal
sys.setrecursionlimit(1000000)
INF = 10 ** 18
MOD = 10 ** 9 + 7
yes = 'Yes'
no = 'No'
from random import randint

def II():
	return int(input())

def SI():
	return str(input())

def MI():
	return map(int, input().split())

def MS():
	return map(str, input().split())

def LI():
	return list(map(int, input().split()))

def LS():
	return list(map(str, input().split()))

def diamondMiner(N, d, m):
	d = sorted(d)
	m = sorted(m)
	e = 0
	for i in range(N):
		e += sqrt(d[i] * d[i] + m[i] * m[i])
	return e
for _ in range(int(input())):
	N = int(input())
	d = []
	m = []
	for _ in range(2 * N):
		(x, y) = map(int, input().split())
		if y == 0:
			d.append(abs(x))
		else:
			m.append(abs(y))
	print(diamondMiner(N, d, m))


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	miner = []
	dia = []
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if y == 0:
			miner.append(abs(x))
		else:
			dia.append(abs(y))
	miner.sort()
	dia.sort()
	ans = 0
	for (m, d) in zip(miner, dia):
		ans += (m ** 2 + d ** 2) ** 0.5
	print(ans)
for _ in range(int(input())):
	main()


t = int(input())
for _ in range(t):
	n = int(input())
	xcor = []
	ycor = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			xcor.append(abs(y))
		else:
			ycor.append(abs(x))
	xcor.sort()
	ycor.sort()
	sum = 0
	for j in range(n):
		temp = xcor[j] ** 2 + ycor[j] ** 2
		sum += temp ** 0.5
	print(sum)


import math
t = int(input())
for i in range(t):
	n = int(input())
	miner = []
	mine = []
	for i in range(2 * n):
		(x, y) = map(int, input().split(' '))
		if x == 0:
			miner.append(abs(y))
		else:
			mine.append(abs(x))
	miner.sort()
	mine.sort()
	sm = 0
	for i in range(n):
		sm += math.sqrt(miner[i] * miner[i] + mine[i] * mine[i])
	print(sm)


import math
t = int(input())
for i in range(t):
	n = int(input())
	lx = []
	ly = []
	for _ in range(2 * n):
		(x, y) = map(int, input().split())
		if y == 0:
			lx.append(abs(x))
		else:
			ly.append(abs(y))
	lx.sort()
	ly.sort()
	ans = 0
	for pp in range(n):
		ans += math.sqrt(lx[pp] * lx[pp] + ly[pp] * ly[pp])
	print(ans)


import math
import string

def main_function():
	test_cases = range(int(input()))
	for test_case in test_cases:
		n = int(input())
		miners = []
		diamonds = []
		for i in range(2 * n):
			(a, b) = [int(i) for i in input().split(' ')]
			if a == 0:
				miners.append(b)
			else:
				diamonds.append(a)
		miners.sort(key=lambda x: abs(x))
		diamonds.sort(key=lambda x: abs(x))
		adder = 0
		for i in range(len(miners)):
			adder += math.sqrt(miners[i] ** 2 + diamonds[i] ** 2)
		print(adder)
main_function()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = []
	b = []
	for _ in range(n * 2):
		(x, y) = list(map(int, sys.stdin.readline().split()))
		if x == 0:
			b.append(y * y)
		else:
			a.append(x * x)
	a.sort()
	b.sort()
	d = 0
	for i in range(n):
		d = d + (a[i] + b[i]) ** 0.5
	print(d)


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	from math import hypot
	input = sys.stdin.buffer.readline
	for _ in range(int(input())):
		N = int(input())
		X = []
		Y = []
		for _ in range(N * 2):
			(x, y) = map(int, input().split())
			if x == 0:
				Y.append(abs(y))
			else:
				X.append(abs(x))
		X.sort()
		Y.sort()
		ans = 0
		for (x, y) in zip(X, Y):
			ans += hypot(x, y)
		print(ans)
main()


for _ in range(int(input())):
	a = int(input())
	ans = 0
	x = []
	y = []
	for i in range(2 * a):
		(x1, y1) = map(int, input().split())
		if x1 == 0:
			y.append(y1 ** 2)
		else:
			x.append(x1 ** 2)
	x.sort()
	y.sort()
	for i in range(a):
		ans += (x[i] + y[i]) ** 0.5
	print(ans)


from math import dist
for _ in range(int(input())):
	n = int(input())
	miner = []
	diamond = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			miner.append(abs(y))
		else:
			diamond.append(abs(x))
	miner.sort()
	diamond.sort()
	ans = 0
	for i in range(n):
		ans += dist((0, miner[i]), (diamond[i], 0))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		if x == 0:
			b.append(abs(y))
		else:
			a.append(abs(x))
	a.sort()
	b.sort()
	ans = 0
	for i in range(n):
		ans += (1.0 * a[i] ** 2 + 1.0 * b[i] ** 2) ** (1 / 2)
	print(ans)


testcases = int(input())
import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
import math
for testcase in range(testcases):
	n = int(input())
	miner = []
	diamond = []
	output = []
	ranges = []
	ans = 0
	for i in range(2 * n):
		temparr = get_ints()
		x = temparr[0]
		y = temparr[1]
		if x == 0:
			miner.append(abs(y))
		else:
			diamond.append(abs(x))
	miner = sorted(miner)
	diamond = sorted(diamond)
	ans = 0
	for i in range(n):
		ans += math.sqrt(miner[i] * miner[i] + diamond[i] * diamond[i])
	print(ans)


import sys, os
if os.environ['USERNAME'] == 'kissz':
	inp = open('in.txt', 'r').readline

	def debug(*args):
		print(*args, file=sys.stderr)
else:
	inp = sys.stdin.readline

	def debug(*args):
		pass
for _ in range(int(inp())):
	n = int(inp())
	M = []
	P = []
	for i in range(2 * n):
		(x, y) = map(int, inp().split())
		if x == 0:
			M += [abs(y)]
		else:
			P += [abs(x)]
	M.sort()
	P.sort()
	r = 0
	for (m, p) in zip(M, P):
		r += (m ** 2 + p ** 2) ** 0.5
	print(r)


from math import sqrt
t = int(input())
for i in range(t):
	n = int(input())
	x_axis = []
	y_axis = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		(x, y) = (abs(x), abs(y))
		if x == 0:
			y_axis.append(y)
		else:
			x_axis.append(x)
	x_axis = sorted(x_axis)
	y_axis = sorted(y_axis)
	total = 0
	for i in range(n):
		total += sqrt(x_axis[i] ** 2 + y_axis[i] ** 2)
	print(total)


inn = lambda : int(input())
inm = lambda : map(int, input().split())
ins = lambda : str(input())
ina = lambda : list(map(int, input().split()))
from math import sqrt

def solve():
	n = inn()
	a = []
	b = []
	for i in range(2 * n):
		(x, y) = inm()
		if x == 0:
			a.append(abs(y))
		else:
			b.append(abs(x))
	a.sort()
	b.sort()
	ans = 0
	for (i, v) in enumerate(a):
		w = b[i]
		ans += sqrt(v * v + w * w)
	print(ans)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


def solve():
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		(x_temp, y_temp) = input().split()
		x_temp = abs(int(x_temp))
		y_temp = abs(int(y_temp))
		if y_temp == 0:
			x.append(x_temp)
		else:
			y.append(y_temp)
	x = sorted(x)
	y = sorted(y)
	ans = 0
	for i in range(len(x)):
		ans += (x[i] * x[i] + y[i] * y[i]) ** 0.5
	print('%.9f' % ans)
	return 0
t = int(input())
while t:
	solve()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	miners = []
	mines = []
	for i in range(2 * n):
		(x, y) = input().split()
		x = int(x)
		y = int(y)
		if x == 0:
			miners.append(abs(y))
		if y == 0:
			mines.append(abs(x))
	mines.sort()
	miners.sort()
	sum = 0
	for i in range(n):
		sum += (mines[i] ** 2 + miners[i] ** 2) ** 0.5
	print(sum)


for testis in range(int(input())):
	n = int(input())
	(x, y) = ([], [])
	for i in range(2 * n):
		(xi, yi) = map(int, input().split())
		if xi:
			x.append(xi ** 2)
		else:
			y.append(yi ** 2)
	x.sort()
	y.sort()
	ans = 0
	for i in range(n):
		ans += (x[i] + y[i]) ** 0.5
	print(ans)


import sys
input = sys.stdin.buffer.readline
for t in range(int(input())):
	N = int(input())
	X = []
	Y = []
	for i in range(2 * N):
		(a, b) = map(int, input().split())
		a = abs(a)
		b = abs(b)
		if a:
			X.append(a)
		else:
			Y.append(b)
	X.sort()
	Y.sort()
	ANS = 0
	for i in range(N):
		ANS += (X[i] * X[i] + Y[i] * Y[i]) ** 0.5
	print(ANS)


import math
m = int(input())
for i in range(m):
	n = int(input())
	i = 0
	listminer = []
	listmines = []
	while i < 2 * n:
		(x, y) = [abs(int(x)) for x in input().split()]
		if x == 0 and y == 0:
			exit()
		i = i + 1
		if x == 0:
			listminer.append(y)
			continue
		if y == 0:
			listmines.append(x)
			continue
	listminer.sort()
	listmines.sort()
	j = 0
	energy = 0
	while j < n:
		energy = energy + math.sqrt(listmines[j] * listmines[j] + listminer[j] * listminer[j])
		j = j + 1
	print(energy)


from sys import stdin
from math import sqrt
input = lambda : stdin.readline().strip()
ipnut = input
yes = 'YES'
no = 'NO'
for _ in range(int(input())):
	n = int(input())
	al = []
	sh = []
	for i in range(2 * n):
		(y, x) = map(int, input().split())
		if x == 0:
			al.append(y)
		else:
			sh.append(x)
	al.sort(key=abs)
	sh.sort(key=abs)
	ans = 0
	for i in range(n):
		ans += sqrt(al[i] ** 2 + sh[i] ** 2)
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	(x, y) = ([], [])
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			y.append(b ** 2)
		else:
			x.append(a ** 2)
	x.sort()
	y.sort()
	ans1 = 0
	for i in range(n):
		ans1 += (x[i] + y[i]) ** 0.5
	y = y[::-1]
	ans = 0
	for i in range(n):
		ans = ans + (x[i] + y[i]) ** 0.5
	print(min(ans, ans1))


from math import sqrt
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	dim = []
	mi = []
	for i in range(2 * n):
		(l, r) = map(int, input().split())
		if l == 0:
			mi.append((l, abs(r)))
		else:
			dim.append((abs(l), r))
	mi.sort()
	dim.sort()
	ans = 0
	for i in range(n):
		ans += sqrt((mi[i][0] - dim[i][0]) ** 2 + (mi[i][1] - dim[i][1]) ** 2)
	print(ans)
	t -= 1


import sys, math
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	n = int(sys.stdin.readline().rstrip())
	miners = []
	mines = []
	for _ in range(2 * n):
		loc = tuple(map(int, sys.stdin.readline().rstrip().split()))
		if loc[0] == 0:
			miners.append(abs(loc[1]))
		else:
			mines.append(abs(loc[0]))
	miners.sort()
	mines.sort()
	energy = 0
	for _ in range(n):
		miner = miners.pop()
		mine = mines.pop()
		energy += math.sqrt(miner ** 2 + mine ** 2)
	print(energy)


import sys
from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	x = []
	y = []
	for i in range(2 * n):
		(X, Y) = map(int, stdin.readline().split())
		X = abs(X)
		Y = abs(Y)
		if Y == 0:
			x.append(X)
		else:
			y.append(Y)
	ans = 0
	x.sort()
	y.sort()
	for i in range(n):
		ans += (x[i] ** 2 + y[i] ** 2) ** 0.5
	print(ans)


import math
n = int(input())
while n:
	X = []
	Y = []
	k = 0
	indx = indy = 1
	m = int(input())
	k = m
	m *= 2
	while m:
		cur_val = input()
		if cur_val[0] == '0':
			X.append(abs(int(cur_val[2:])))
			indx = indx + 1
		else:
			Y.append(abs(int(cur_val[:-2])))
			indy = indy + 1
		m = m - 1
	X.sort()
	Y.sort()
	indx = indy = s = 0
	d = 0
	while k:
		d += (X[indx] ** 2 + Y[indx] ** 2) ** 0.5
		k = k - 1
		indx = indx + 1
	print(d)
	n = n - 1


from collections import Counter, deque
import math
from random import randint
from bisect import bisect
import sys
import re
import copy
MOD = 1000000007
MAX = sys.maxsize
MIN = -sys.maxsize

class get:

	def int():
		return list(map(int, input().split()))

	def str():
		return input().split()

	def float():
		return list(map(float, input().split()))

	def map():
		return map(int, input().split())

def sqrt(x):
	return int(math.sqrt(x)) + 1

def gcd(*args):
	result = args[0]
	for item in args:
		result = math.gcd(result, item)
	return result

def LCM(a, b):
	return a * b // math.gcd(a, b)

def value(n):
	if n % 2 == 1:
		return 2
	else:
		for i in range(3, n, 2):
			if n % i != 0:
				return i

def solve():
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		(a, b) = get.map()
		if a == 0:
			y.append(b * b)
		else:
			x.append(a * a)
	x.sort()
	y.sort()
	res = 0
	for i in range(n):
		res += math.sqrt(x[i] + y[i])
	print(res)
for _ in range(int(input())):
	solve()


from math import sqrt

def solve(_mines, _miners):
	_mines = sorted(_mines)
	_miners = sorted(_miners)
	ans = 0.0
	for (mine, miner) in zip(_mines, _miners):
		ans += sqrt(mine ** 2 + miner ** 2)
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	mines = []
	miners = []
	for _ in range(2 * n):
		(x, y) = map(int, input().split(' '))
		if x == 0:
			mines.append(abs(y))
		else:
			miners.append(abs(x))
	print(solve(mines, miners))


import math
sq = lambda x: x * x

def solv(xl, yl):
	n = len(xl)
	xl = list(map(sq, xl))
	yl = list(map(sq, yl))
	xl.sort()
	yl.sort()
	zl = [xl[i] + yl[i] for i in range(n)]
	zl = list(map(math.sqrt, zl))
	return sum(zl)
for _ in range(int(input())):
	n = int(input())
	xl = []
	yl = []
	for i in range(n << 1):
		(x, y) = map(int, input().split())
		if x == 0:
			yl.append(y)
		else:
			xl.append(x)
	print(solv(xl, yl))


t = int(input())
import math
r = []
for i in range(t):
	s = 0
	a = []
	b = []
	n = int(input())
	for j in range(2 * n):
		x = list(map(int, input().split()))
		if x[0] == 0:
			b.append(abs(x[1]))
		else:
			a.append(abs(x[0]))
	a.sort()
	b.sort()
	for j in range(n):
		s = s + math.sqrt(a[j] * a[j] + b[j] * b[j])
	r.append(s)
for i in range(len(r)):
	print(r[i])


import math
import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		miners = []
		diamonds = []
		for i in range(n * 2):
			(x, y) = map(int, input().split())
			if x == 0:
				miners.append(abs(y))
			if y == 0:
				diamonds.append(abs(x))
		miners.sort()
		diamonds.sort()
		ans = 0
		for i in range(n):
			(x, y) = (diamonds[i], miners[i])
			ans += math.sqrt(x ** 2 + y ** 2)
		print(ans)
main()


from math import sqrt
casos = int(input())
for i in range(casos):
	soma = 0
	n = int(input())
	mineradores = []
	minas = []
	for j in range(2 * n):
		(a, b) = [int(x) for x in input().split(' ')]
		if a == 0:
			mineradores.append(abs(b))
		else:
			minas.append(abs(a))
	mineradores.sort()
	minas.sort()
	for j in range(n):
		soma += sqrt(mineradores[j] ** 2 + minas[j] ** 2)
	print('%.15f' % soma)


import math
t = int(input())
for i in range(t):
	n = int(input())
	miner = []
	diamond = []
	for j in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			miner.append(abs(b))
		else:
			diamond.append(abs(a))
	miner.sort()
	diamond.sort()
	total = 0
	for j in range(n):
		total += math.sqrt(pow(miner[j], 2) + pow(diamond[j], 2))
	print(total)


import math
for _ in range(int(input())):
	n = int(input())
	x = []
	y = []
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			y.append(abs(b))
		else:
			x.append(abs(a))
	x = sorted(x)
	y = sorted(y)
	ans = 0
	for i in range(len(x)):
		ans += math.sqrt(x[i] * x[i] + y[i] * y[i])
	print(round(ans, 15))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	miners = []
	diamonds = []
	for _ in range(2 * n):
		xy = input().split(' ')
		x = int(xy[0])
		y = int(xy[1])
		if x == 0:
			miners.append(abs(y))
		elif y == 0:
			diamonds.append(abs(x))
	miners.sort()
	diamonds.sort()
	d = 0.0
	for m in range(len(miners)):
		mx = 0
		my = miners[m]
		dx = diamonds[m]
		dy = 0
		d += math.sqrt((mx - dx) * (mx - dx) + (my - dy) * (my - dy))
	print(d)


import math

def diamondMiner(N, d, m):
	d = sorted(d)
	m = sorted(m)
	e = 0
	for i in range(N):
		e += math.sqrt(d[i] * d[i] + m[i] * m[i])
	return e
for _ in range(int(input())):
	N = int(input())
	d = []
	m = []
	for _ in range(2 * N):
		(x, y) = map(int, input().split())
		if y == 0:
			d.append(abs(x))
		else:
			m.append(abs(y))
	print(diamondMiner(N, d, m))


for t in range(int(input())):
	miners = []
	mines = []
	for n in range(int(input()) * 2):
		sub = input().split()
		if sub[0] == '0':
			miners.append(abs(int(sub[1])))
		else:
			mines.append(abs(int(sub[0])))
	miners.sort()
	mines.sort()
	energy = 0
	for i in range(len(miners)):
		energy += (mines[i] ** 2 + miners[i] ** 2) ** 0.5
	print(energy)


import math
import sys
from functools import reduce
import decimal
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def inp():
	return sys.stdin.readline().strip()

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	n = int(inp())
	minors = []
	mines = []
	for i in range(2 * n):
		(x, y) = map_inp(int)
		if y == 0:
			mines.append(abs(x))
		else:
			minors.append(abs(y))
	minors.sort()
	mines.sort()
	ans = 0
	for (i, j) in zip(mines, minors):
		ans += math.sqrt(i * i + j * j)
	print(ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	mine = []
	diam = []
	for j in range(2 * n):
		(x, y) = [int(k) for k in input().split()]
		if x == 0:
			mine.append(abs(y))
		else:
			diam.append(abs(x))
	mine.sort()
	diam.sort()
	fin = 0
	for j in range(n):
		fin += math.sqrt(mine[j] ** 2 + diam[j] ** 2)
	print(fin)


from math import sqrt

def main():
	for _ in range(int(input())):
		m = []
		n = []
		for i in range(2 * int(input())):
			(x, y) = list(map(int, input().split()))
			if x == 0:
				m.append(abs(y))
			else:
				n.append(abs(x))
		soma = 0
		n.sort()
		m.sort()
		for i in range(len(m) - 1, -1, -1):
			soma += sqrt(m[i] ** 2 + n[i] ** 2)
		print(soma)
main()


import math

def solv(xl, yl):
	n = len(xl)
	xl = [x * x for x in xl]
	yl = [y * y for y in yl]
	xl.sort()
	yl.sort()
	ans = 0
	for i in range(n):
		ans += math.sqrt(xl[i] + yl[i])
	return ans
for _ in range(int(input())):
	n = int(input())
	xl = []
	yl = []
	for i in range(n << 1):
		(x, y) = map(int, input().split())
		if x == 0:
			yl.append(y)
		else:
			xl.append(x)
	print(solv(xl, yl))


from math import sqrt
tc = int(input())
for _ in range(tc):
	x = []
	y = []
	n = int(input())
	for _ in range(2 * n):
		(a, b) = map(int, input().split())
		if a == 0:
			y.append(abs(b))
		else:
			x.append(abs(a))
	y = sorted(y)
	x = sorted(x)
	total = 0
	for i in range(len(x)):
		total += sqrt(x[i] ** 2 + y[i] ** 2)
	print(total)


Cases = range(1, int(input()) + 1)
from heapq import heappush as pushq
from heapq import heappop as popq
for case in Cases:
	inputs = int(input())
	miners = []
	diamonds = []
	for _ in range(inputs * 2):
		(x, y) = map(int, input().split())
		if x == 0:
			pushq(miners, abs(y))
		else:
			pushq(diamonds, abs(x))
	answer = 0
	for _ in range(inputs):
		answer += (popq(miners) ** 2 + popq(diamonds) ** 2) ** 0.5
	print(answer)