#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
using namespace std;
typedef long long int ll; typedef pair <int, int> P;
const double INF = 1000000000; const double EPS = 10e-9;
int x1[100], y[100], x2[100], z[100];
double width(int *X, int *Y, int n, double x) {
	double lb = -INF, ub = INF;
	for (int i = 0; i < n; i++)
	{
		double x1 = X[i], x2 = X[(i + 1) % n], y1 = Y[i], y2 = Y[(i + 1) % n];
		if ((x1 - x) * (x2 - x) > 0 || x1 == x2) continue;
		double y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
		lb = max(lb, y);
		ub = min(ub, y);
	}
	return max(0.0, lb - ub);
}
int main()
{
	while (true)
	{
		vector <int> x;
		int m, n; cin >> m >> n;
		if (m == 0 && n == 0) break;
		for (int i = 0; i < m; i++) {
			cin >> x1[i] >> y[i];
			x.push_back(x1[i]);
		}
		for (int i = 0; i < n; i++) {
			cin >> x2[i] >> z[i];
			x.push_back(x2[i]);
		}
		int minx1 = *min_element(x1, x1 + m), maxx1 = *max_element(x1, x1 + m);
		int minx2 = *min_element(x2, x2 + n), maxx2 = *max_element(x2, x2 + n);
		sort(x.begin(), x.end());
		double res = 0.0;
		for (int i = 0; i + 1 < m + n; i++)
		{
			double a = x[i], b = x[i + 1], c = (a + b) / 2;
			if (minx1 < c && c < maxx1 && minx2 < c && c < maxx2)
			{
				double sa = width(x1, y, m, a) * width(x2, z, n, a);
				double sb = width(x1, y, m, b) * width(x2, z, n, b);
				double sc = width(x1, y, m, c) * width(x2, z, n, c);
				res += (b - a) / 6 * (sa + sb + 4 * sc);
			}
		}
		printf("%.10f\n", res);
	}
	return 0;
}