#include <algorithm>
#include <vector>
#include <complex>
#include <cstdio>
using namespace std;

#define rep(i,a,b) for(__typeof(b) i=a; i<(b); ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef complex<long double> point;
typedef vector<int> vi;

long double f(long double x, long double h, long double l)
{
    return (h + l) * x * x / 2 - pow(x, 3) / 3;
}

double eps = 1e-8;

long double integr(point a, point b)
{
    if (abs(a - b) < 1e-10) return 0;
    imag(a) = abs(imag(a));
    imag(b) = abs(imag(b));
    long double h = min(imag(a), imag(b)),
           d = real(b) - real(a),
           l = abs(imag(a) - imag(b));
    long double res = d * h * h / 2;
    if (abs(l) > eps)
        return res + d / l * (f(h + l, h, l) - f(h, h, l));
    return res;
}

bool kde(point &a, point &b)
{
    return imag(a) + imag(b) > 0;
}

int main()
{
    int t; scanf("%d", &t);
    rep(cases,0,t)
    {
        int n; scanf("%d", &n);
        vector<point> x(n);
        rep(i,0,n) scanf("%Lf %Lf", &real(x[i]), &imag(x[i]));

        double S = 0, res = 0;
        rep(j,0,n)
        {
            point smer = x[(j + 1) % n] - x[j];
            S += real(smer) * (imag(smer) / 2 + imag(x[j]));
            smer /= abs(smer);
            point zero = x[j] / smer;
            double plocha[2] = {0, 0};

            rep(i,0,n) if (i != j)
            {
                point a = x[i] / smer - zero, b = x[(i + 1) % n] / smer - zero;
                if (imag(a) * imag(b) < 0)
                {
                    long double t = imag(b) / (imag(b) - imag(a));
                    point c = t * a + (1 - t) * b;
                    plocha[kde(a, c)] += integr(a, c);
                    plocha[kde(c, b)] += integr(c, b);
                }
                else plocha[kde(a, b)] += integr(a, b);
            }
            res += abs(plocha[0]) + abs(plocha[1]);
        }

        printf("%.12lf\n", res / abs(S));
    }
}
