require 'set'

def compress(used_x)
	x_map = {}
	used_x.to_a.uniq.sort.each_with_index{|x, i| x_map[x] = i}
	x_map
end

loop do
    n = gets.to_i
    break if n == 0
    used_x = Set.new
    used_y = Set.new
    w_points = []
    n.times do
        x, y = gets.split.map(&:to_i)
        used_x << x
        used_y << y
        w_points << [x, y]
    end

    x_min = Float::INFINITY
    x_max = - x_min
    y_min = Float::INFINITY
    y_max = - y_min

    4.times do
        x, y = gets.split.map(&:to_i)
        used_x << x
        x_max = x if x > x_max
        x_min = x if x < x_min
        used_y << y
        y_max = y if y > y_max
        y_min = y if y < y_min
    end

    cx = compress(used_x)
    cy = compress(used_x)

    v_lines = []
    (w_points + [w_points[0]]).each_cons(2) do |p1, p2|
        x1, y1 = p1
        x2, y2 = p2
        next if x1 != x2
        y1, y2 = y2, y1 if y1 > y2
        v_lines << [cx[x1], cy[y1], cy[y2]]#
    end
    v_lines.sort_by!(&:first)

#    a = (0..cx.values.max).map { [0] * (cy.values.max + 1) }

#    (0..cy.values.max).each do |y|
#        crossed = v_lines.select {|x, y1, y2| y1 <= y && y < y2 }
#        crossed.each_slice(2) do |l1, l2|
#            x1, _, _ = l1
#            x2, _, _ = l2
#            (x1..x2-1).each do |x|
#                a[x][y] = 1
#            end
#        end
#    end

#    (cy[y_min]..cy[y_max]-1).each do |y|
#        (cx[x_min]..cx[x_max]-1).each do |x|
#            a[x][y] = 0
#        end
#    end

#    cx_inv = cx.invert
#    cy_inv = cy.invert

    s = 0
#    (0..cy.values.max).each do |y|
#        (0..cx.values.max).each do |x|
#            s += (cx_inv[x+1] - cx_inv[x]) * (cy_inv[y+1] - cy_inv[y]) if a[x][y] == 1
#        end
#    end

    p s
end