The Ministry of Emergency Situations (MES) was
informed about the fall of a large meteorite that exploded in the atmosphere. The
employees promptly examined the impact site and mapped the affected area in
detail.
It turned out that the affected area is
bounded by a complex-shape polygon M. Unfortunately, there is a
large city in this area. The boundaries of the city also represent a polygon, G.
It is natural to expect that the major damage requiring the intervention of MES
occurred at the intersection of polygons M and G.
As an urgent measure, it was decided to
calculate the number of separate parts of the city falling into the major
damage zone. Note that none of the vertices of polygons M and G
lies on the boundary of another polygon.
Write a program that
calculates the number of parts in the intersection of polygons M
and G.
Input
The
first line contains integer N, the number of vertices in polygon M.
The following N lines contain the coordinates of the vertices of M
in the order of contour traversal. Coordinate values are separated with one or
several space characters.
The
next line contains integer K, the number of vertices in G,
and the following K lines contain the coordinates of its
vertices.
Output
Output
a single number – the count of separate parts in the intersection of polygons M
and G.
Limitations
3
≤ N, K ≤ 300
All
coordinates are non-negative integers not exceeding 32000.
Example
Input
|
Output
|
4
0 0
3 5
7 1
4 3
3
2 2
2 0
7 2
|
2
|