from sys import stdin
from math import hypot
def int_reader():
for x in stdin.read().split(): yield int(x)
nextint = int_reader().next
T = nextint()
for t in range(T):
N = nextint()
A = []
for n in range(N): A.append( (nextint(),nextint()) )
result = 0
for n in range(N/2):
x1, y1 = A[n]
x2, y2 = A[(n+1)%N]
x3, y3 = A[(n+N/2)%N]
x4, y4 = A[(n+N/2+1)%N]
ux, uy = x2-x1, y2-y1
nlen = hypot(ux,uy)
nx, ny = uy/nlen, -ux/nlen
wx, wy = x4-x1, y4-y1
dist = abs(nx * wx + ny * wy)
result += dist
print "%.12f" % result