
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <map>
#include <math.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=105;
int n,m;
int X1[N],Y1[N],X2[N],Z2[N];

db width(int* x,int *y,int n,db xx) {
    db lb=INF,ub=-INF;
    for (int i=0;i<n;i++) {
        db xx1=x[i],yy1=y[i],xx2=x[(i+1)%n],yy2=y[(i+1)%n];
        if ((xx1-xx)*(xx2-xx)<=0&&xx1!=xx2) {
            db yy=yy1+(yy2-yy1)*(xx-xx1)/(xx2-xx1);
            lb=min(lb,yy);
            ub=max(ub,yy);
        }
    }
    return max(0.0,ub-lb);
}

int main()
{
    while (true) {
        scanf("%d%d",&m,&n);
        if (m==0&&n==0) break;
        for (int i=0;i<m;i++) { scanf("%d%d",X1+i,Y1+i); }
        for (int i=0;i<n;i++) { scanf("%d%d",X2+i,Z2+i); }
        int mn1=*min_element(X1,X1+m),mx1=*max_element(X1,X1+m);
        int mn2=*min_element(X2,X2+n),mx2=*max_element(X2,X2+n);
        vector<int> xs;
        for (int i=0;i<m;i++) xs.pb(X1[i]);
        for (int i=0;i<n;i++) xs.pb(X2[i]);
        sort(xs.begin(),xs.end());
        db ans=0.0;
        for (int i=0;i+1<xs.size();i++) {
            db a=xs[i],b=xs[i+1],c=(a+b)/2;
            if (mn1<=c&&c<=mx1&&mn2<=c&&c<=mx2) {
                db fa=width(X1,Y1,m,a)*width(X2,Z2,n,a);
                db fb=width(X1,Y1,m,b)*width(X2,Z2,n,b);
                db fc=width(X1,Y1,m,c)*width(X2,Z2,n,c);
                ans+=(b-a)/6*(fa+4*fc+fb);
            }
        }
        printf("%.10lf\n",ans);
    }
}
