package main
import (
"fmt"
"math"
"os"
"sort"
)
type int64Slice []int64
func (p int64Slice) Len() int { return len(p) }
func (p int64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p int64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func main() {
buf := make([]byte, 65536)
var pos, length int
readByte := func() byte {
if pos >= length {
pos = 0
n, _ := os.Stdin.Read(buf)
if n == 0 {
return 0
}
length = n
}
b := buf[pos]
pos++
return b
}
readInt := func() int64 {
var b byte
for {
b = readByte()
if b == 0 || b > 32 {
break
}
}
if b == 0 {
return 0
}
neg := false
if b == '-' {
neg = true
b = readByte()
}
var res int64
for b > 32 {
res = res*10 + int64(b-'0')
b = readByte()
}
if neg {
return -res
}
return res
}
t := int(readInt())
for i := 0; i < t; i++ {
n := int(readInt())
xs := make(int64Slice, 0, n)
ys := make(int64Slice, 0, n)
for j := 0; j < 2*n; j++ {
x := readInt()
y := readInt()
if x == 0 {
if y < 0 {
ys = append(ys, -y)
} else {
ys = append(ys, y)
}
} else {
if x < 0 {
xs = append(xs, -x)
} else {
xs = append(xs, x)
}
}
}
sort.Sort(xs)
sort.Sort(ys)
var ans float64
for j := 0; j < n; j++ {
ans += math.Sqrt(float64(xs[j]*xs[j] + ys[j]*ys[j]))
}
fmt.Printf("%.15f\n", ans)
}
}