### constant

INF = Float::INFINITY

### classes

class Pt
  attr_accessor :x, :y

  def initialize() end
  def initialize(_x, _y) @x = _x; @y = _y end

  def ==(pt) @x == pt.x && @y == pt.y end
  def +(pt) Pt.new(@x + pt.x, @y + pt.y) end
  def -(pt) Pt.new(@x - pt.x, @y - pt.y) end
  def -@() Pt.new(-@x, -@y) end
  def *(t) Pt.new(@x * t, @y * t) end
  def /(t) Pt.new(@x / t, @y / t) end
  def dot(v) @x * v.x + @y * v.y end
  def cross(v) @x * v.y - @y * v.x end
  def d2() @x * @x + @y * @y end
  def d() Math.sqrt(d2()) end
  def normalize() self / d() end
  def to_s() "(#{@x},#{@y})" end
  def to_a() [@x, @y] end
end

### subroutines

def cutlen(x, ys, k)
  miny = INF
  maxy = -INF
  for i in (0...k)
    pt0 = ys[i]
    pt1 = ys[(i + 1) % k]
    v = pt1 - pt0
    if v.x != 0.0 && (pt0.x <= x && x <= pt1.x || pt1.x <= x && x <= pt0.x)
      y = v.y * (x - pt0.x) / v.x + pt0.y
      miny = y if miny > y
      maxy = y if maxy < y
    end
  end

  (maxy >= miny) ? maxy - miny : 0.0
end

### main

loop do
  m, n = gets.split.map(&:to_i)
  break if (m | n) == 0

  xys = m.times.map{Pt.new(*gets.split.map(&:to_f))}
  xzs = n.times.map{Pt.new(*gets.split.map(&:to_f))}
  #p [xys.map{|pt| pt.to_s}, xzs.map{|pt| pt.to_s}]

  xmin0 = xys.map{|pt| pt.x}.min
  xmax0 = xys.map{|pt| pt.x}.max
  xmin1 = xzs.map{|pt| pt.x}.min
  xmax1 = xzs.map{|pt| pt.x}.max

  xs = (xys.map{|pt| pt.x} + xzs.map{|pt| pt.x}).sort.uniq
  nxs = xs.length
  #p [xmin0, xmax0, xmin1, xmax1]
  #p xs

  dys = nxs.times.map{0.0}
  dzs = nxs.times.map{0.0}
  for i in (0...nxs)
    xi = xs[i]
    if xmin0 <= xi && xi <= xmax0
      dys[i] = cutlen(xi, xys, m)
    end
    if xmin1 <= xi && xi <= xmax1
      dzs[i] = cutlen(xi, xzs, n)
    end
  end
  #p [dys, dzs]
  
  vol = 0.0

  (0...nxs).each_cons(2) do |i0, i1|
    x0 = xs[i0]
    x1 = xs[i1]
    if xmin0 <= x0 && x1 <= xmax0 && xmin1 <= x0 && x1 <= xmax1
      dy0 = dys[i0]
      dz0 = dzs[i0]
      dy1 = dys[i1]
      dz1 = dzs[i1]
      v = (x1 - x0) * (dy0 * dz1 + dy1 * dz0 + 2 * (dy0 * dz0 + dy1 * dz1)) / 6
      vol += v
    end
  end

  puts vol
end