// BAPC06 Geodes, Marijn Kruisselbrink
#include <stdio.h>
#include <math.h>

#define MAXPOINTS 65535
#define INF 1000000000

#define READINT() ({ int __foo; scanf("%d", &__foo); __foo; })
#define REP(var, max) for (var = 0; var < (max); var++)
#define PRED(a) (&(a)[-1])
#define LERP(a, b, u) ({ typeof(u) __u = (u); (a * __u) + (b * (1- __u)); })
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef struct point {int x, y;} point;
typedef struct line {int h;	double w;} line;

void readPoints(point* d, int n, int* h) {
	int i, minx = INF, maxx = -INF, miny = INF, maxy = -INF;
	REP(i, n) {
		d[i].x = READINT();
		d[i].y = READINT();
		if (d[i].x < minx) minx = d[i].x;
		if (d[i].y < miny) miny = d[i].y;
		if (d[i].y > maxy) maxy = d[i].y;
    
	}
	*h = maxy - miny;
	REP(i, n) { d[i].x -= minx; d[i].y -= miny; }
}

void split(point* in, int n, int height, point** left, point** right) {
	int lmin = -1, lmax = -1;
	int rmin = -1, rmax = -1;
	int i;
	REP(i, n) {
		if (in[i].y == 0) {
			if (lmin == -1 || in[lmin].x > in[i].x) lmin = i;
			if (rmin == -1 || in[rmin].x < in[i].x) rmin = i;
		} else if (in[i].y == height) {
			if (lmax == -1 || in[lmax].x > in[i].x) lmax = i;
			if (rmax == -1 || in[rmax].x < in[i].x) rmax = i;
		}
	}
	for (i = lmin; i != lmax; i = (i + 1) % n) *((*left)++) = in[i]; *((*left)++) = in[lmax];
	for (i = rmin; i != rmax; i = (i - 1 + n) % n) *((*right)++) = in[i]; *((*right)++) = in[rmax];
}

void merge(point* l, point* lend, point* r, point* rend, line** out) {
	while (l < lend && r < rend) {
		if (l->y == r->y) {
			*((*out)++) = (line){l->y, r->x - l->x}; l++; r++;
		} else if (l->y < r->y) {
			*((*out)++) = (line){l->y, PRED(r)->x + (r->x - PRED(r)->x)*((double)(l->y - PRED(r)->y) / (r->y - PRED(r)->y)) - l->x}; l++;
		} else {
			*((*out)++) = (line){r->y, r->x - PRED(l)->x - (l->x - PRED(l)->x)*((double)(r->y - PRED(l)->y) / (l->y - PRED(l)->y))}; r++;
		}
	}
}

double volume(line* a, line* aend, line* b, line* bend) {
	typedef struct st { int h; double wa; double wb; } st;
	st last = {0, 0, 0}, cur;
	double vol = 0;
	while (a < aend && b < bend) {
		if (a->h == b->h) {
			cur = (st){a->h, a->w, b->w}; ++a; ++b;
		} else if (a->h < b->h) {
			cur = (st){a->h, a->w, LERP(PRED(b)->w, b->w, (double)(b->h - a->h) / (b->h - PRED(b)->h))}; ++a;
		} else {
			cur = (st){b->h, LERP(PRED(a)->w, a->w, (double)(a->h - b->h) / (a->h - PRED(a)->h)), b->w}; ++b;
		}
		vol += (cur.h - last.h) * (2 * cur.wa * cur.wb + 2 * last.wa * last.wb + cur.wa * last.wb + cur.wb * last.wa) / 6;
		last = cur;
	}
	return vol;
}

void solve() {
	point pa[MAXPOINTS], pb[MAXPOINTS];
	int asize, bsize;
	point aleft[MAXPOINTS], aright[MAXPOINTS], bleft[MAXPOINTS], bright[MAXPOINTS];
	point *alend = aleft, *arend = aright, *blend = bleft, *brend = bright;
	int height;
	line la[MAXPOINTS], lb[MAXPOINTS];
	line *aend = la, *bend = lb;
    
	asize = READINT();
	readPoints(pa, asize, &height);
	bsize = READINT();
	readPoints(pb, bsize, &height);

	split(pa, asize, height, &alend, &arend);
	split(pb, bsize, height, &blend, &brend);
	merge(aleft, alend, aright, arend, &aend);
	merge(bleft, blend, bright, brend, &bend);
	printf("%.2f\n", volume(la, aend, lb, bend));
}

int main() {
	for (int n = READINT(); n--;) solve();
   	return 0;
}
