#include<bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=550;
const int inf=0x3f3f3f3f;
int _m,_n;//第一个是m多边形,第二个是n多边形
int X1[105],Y1[105],X2[105],Z2[105];//下标从0开始
double width(int X[],int Y[],int n,double x)//对于n个点的多边形(x,y)
{
    double down=1e8,up=-1e8;
    for(int i=0;i<n;++i)
    {
        int x1=X[i],y1=Y[i],x2=X[(i+1)%n],y2=Y[(i+1)%n];
        if(x1>x2){
            swap(x1,x2);swap(y1,y2);
        }
        if(x>=x1&&x<=x2){
            double y=y1+(x-x1)*(y2*1.0-y1)/(x2-x1);
            down=min(down,y);
            up=max(up,y);
        }
    }
    return max(0.0,up-down);
}
double f(double x)
{
    return width(X1,Y1,_m,x)*width(X2,Z2,_n,x);
}
double Simpson(double a,double b)//要求a<b
{
    double c=(a+b)/2.0;
    return (b-a)/6.0*(f(a)+4*f(c)+f(b));
}
vector<int> sx;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    while(cin>>_m>>_n)
    {
        if(_m==0&&_n==0) return 0;
        sx.clear();
        for(int i=0;i<_m;++i){
            cin>>X1[i]>>Y1[i];
            sx.push_back(X1[i]);
        }
        for(int i=0;i<_n;++i){
            cin>>X2[i]>>Z2[i];
            sx.push_back(X2[i]);
        }
        sort(sx.begin(),sx.end());
        int min1=*min_element(X1,X1+_m),max1=*max_element(X1,X1+_m);
        int min2=*min_element(X2,X2+_n),max2=*max_element(X2,X2+_n);
        double res=0;
        for(int i=0;i+1<sx.size();++i)
        {
            int a=sx[i],b=sx[i+1];
            if(a>=min1&&a<=max1&&a>=min2&&a<=max2&&b>=min1&&b<=max1&&b>=min2&&b<=max2)
            {
                res+=Simpson(a*1.0,b*1.0);
            }
        }
        cout<<fixed<<setprecision(10)<<res<<endl;
    }
}
