#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X!=b.X) ? a.X<b.X : a.Y<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

bool intersectLS(const L& l, const L& s){
    return cross(l[1]-l[0], s[0]-l[0])*
        cross(l[1]-l[0], s[1]-l[0]) < EPS;
}

bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}
P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}

double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}

VP convex_cut(const VP& p, const L& l){
    VP ret;
    int n = p.size();
    for(int i=0; i<n; i++){
        P curr = p[i];
        P next = p[(i+1)%n];
        if(ccw(l[0], l[1], curr) != -1) ret.push_back(curr);
        if(ccw(l[0], l[1], curr) *ccw(l[0], l[1], next) == -1){
            ret.push_back(crosspointLL(L(curr, next), l));
        }
    }
    return ret;
}

struct c2cut{
    double z, x[2];
    c2cut(double z, double xmin, double xmax):z(z),x{xmin, xmax}{}
    c2cut(){}
    bool operator <(const c2cut &a){
        return z < a.z;
    }
    bool operator ==(const c2cut &a){
        return z == a.z;
    }
};

int main(){
    while(1){
        int m,n;
        cin >> m >> n;
        if(n==0) break;
        
        VP c1(m), c2(n);
        for(int i=0; i<m; i++){
            double x,y;
            cin >> x >> y;
            c1[i] = P(x, y);
        }
        for(int i=0; i<n; i++){
            double x,z;
            cin >> x >> z;
            c2[i] = P(x, z);
        }
        
        vector<c2cut> cz(n);
        for(int i=0; i<n; i++){
            double z = c2[i].Y;
            L cutline(P(0, z), P(1, z));
            vector<double> cpx;
            for(int i=0; i<n; i++){
                L edge(c2[i], c2[(i+1)%n]);
                if(!isParallel(cutline, edge) && intersectLS(cutline, edge)){
                    cpx.push_back((crosspointLL(cutline, edge)).X);
                }
            }
            double xmin = *min_element(cpx.begin(), cpx.end());
            double xmax = *max_element(cpx.begin(), cpx.end());
            cz[i] = c2cut(z, xmin, xmax);
        }
        sort(cz.begin(), cz.end());
        cz.erase(unique(cz.begin(), cz.end()), cz.end());

        double ans = 0;
        for(int i=0; i<(int)cz.size()-1; i++){
            vector<double> zdiff;
            for(int d=0; d<2; d++){
                double x[2] = {cz[i].x[d], cz[i+1].x[d]};
                if(abs(x[1]-x[0]) < EPS) continue;
                if(x[0] > x[1]) swap(x[0], x[1]);
                L cut[2] = {L(P(x[1], 0), P(x[1], 1)), L(P(x[0], 1), P(x[0], 0))};
                VP p = convex_cut(c1, cut[0]);
                p = convex_cut(p, cut[1]);
                for(int j=0; j<(int)p.size(); j++){
                    double xdiff = abs(p[j].X -cz[i].x[d]);
                    zdiff.push_back((cz[i+1].z -cz[i].z) *xdiff/(x[1]-x[0]));
                }
            }
            for(int d=0; d<2; d++){
                int xmax = cz[i+d].x[1];
                int xmin = cz[i+d].x[0];
                L cut[2] = {L(P(xmax, 0), P(xmax, 1)), L(P(xmin, 1), P(xmin, 0))};
                VP p = convex_cut(c1, cut[0]);
                p = convex_cut(p, cut[1]);
                if(!p.empty()){
                    zdiff.push_back((cz[i+1].z -cz[i].z) *d);
                }
            }
            sort(zdiff.begin(), zdiff.end());
            zdiff.erase(unique(zdiff.begin(), zdiff.end()), zdiff.end());

            for(int j=0; j<(int)zdiff.size()-1; j++){
                double z[3];
                z[0] = cz[i].z +zdiff[j];
                z[2] = cz[i].z +zdiff[j+1];
                z[1] = (z[0] +z[2])/2;
                double area[3];
                for(int k=0; k<3; k++){
                    L cutline(P(0, z[k]), P(1, z[k]));
                    vector<double> cpx;
                    for(int i=0; i<n; i++){
                        L edge(c2[i], c2[(i+1)%n]);
                        if(!isParallel(cutline, edge) && intersectLS(cutline, edge)){
                            cpx.push_back((crosspointLL(cutline, edge)).X);
                        }
                    }
                    double xmin = *min_element(cpx.begin(), cpx.end());
                    double xmax = *max_element(cpx.begin(), cpx.end());
                    L cut[2] = {L(P(xmax, 0), P(xmax, 1)), L(P(xmin, 1), P(xmin, 0))};
                    VP con = convex_cut(c1, cut[0]);
                    con = convex_cut(con, cut[1]);
                    area[k] = getarea(con);
                }
                ans += (z[2] -z[0])/6 *(area[0] +4*area[1] +area[2]);
            }
        }

        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3268