#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;
typedef pair<double, double> pdd;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
typedef vector<P> G;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
P crosspoint(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]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

double width(int *X, int *Y, int n, double x) {
  double lb = INF, ub = -INF;
  L l = L(P(x,0), P(x,1));
  REP(i, n) {
    L s = L(P(X[i], Y[i]), P(X[(i+1)%n], Y[(i+1)%n]));
    if (intersectLS(l, s)) {
      P p = crosspoint(l, s);
      double y = p.imag();
      lb = min(lb, y);
      ub = max(ub, y);
    }
  }
  return max(0.0, ub-lb);
}
int main() {
  int m, n;
  while(cin >> m >> n, m||n) {
    int X1[m], Y1[m], X2[n], Z2[n];
    REP(i, m) cin >> X1[i] >> Y1[i];
    REP(i, n) cin >> X2[i] >> Z2[i];
    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);
    vector<int> xs;
    REP(i, m) xs.push_back(X1[i]);
    REP(i, n) xs.push_back(X2[i]);
    sort(ALL(xs));

    double res = 0;
    REP(i, xs.size()-1) {
      double a = xs[i], b = xs[i+1], c = (a+b)/2;
      if (min1 <= c && c <= max1 && min2 <= c && c<= max2) {
        double fa = width(X1, Y1, m, a) * width(X2, Z2, n, a);
        double fb = width(X1, Y1, m, b) * width(X2, Z2, n, b);
        double fc = width(X1, Y1, m, c) * width(X2, Z2, n, c);
        res += (b-a) / 6 * (fa + 4*fc + fb);
      }
    }
    printf("%.10f\n", res);
  }
}

Measured memory_bytes: 968