P6886 [COCI 2016/2017 #3] Meksikanac

Description

Norman has a fly swatter shaped as a given $K$-gon. He wants to know how many ways there are to place the fly swatter so that its vertices lie within the rectangle with vertices $(0,0)$ and $(X_p,Y_p)$, and all vertices are lattice points, while making sure that no fly is harmed. Here, a lattice point means a point whose $x$-coordinate and $y$-coordinate are both integers. There are $N$ flies inside this rectangle, and each fly can be treated as a point $(X,Y)$. A fly is harmed if and only if it lies on a vertex, an edge, or in the interior of the fly swatter. The fly swatter cannot be rotated or flipped.

Input Format

The first line contains three positive integers $X_p,Y_p,N$, with the meanings as above. The next $N$ lines each contain two positive integers $(X,Y)$, representing the coordinates of the $i$-th fly. The next line contains a positive integer $K$, denoting the number of vertices of the polygon. The next $K$ lines each contain two integers $(X_i,Y_i)$, describing the coordinates of the vertices when the first vertex of the fly swatter is at $(X_1,Y_1)$. The vertices are given in order.

Output Format

Output the number of feasible ways to place the fly swatter.

Explanation/Hint

### Explanation of the Samples #### Sample 1 Explanation The valid positions of the fly swatter are as follows: ![](https://cdn.luogu.com.cn/upload/image_hosting/n0zxm7n4.png?x-oss-process=image/resize,m_lfit,h_340,w_450) There are $4$ ways in total. #### Sample 2 Explanation The valid positions of the fly swatter are as follows: ![](https://cdn.luogu.com.cn/upload/image_hosting/6mcgzh88.png?x-oss-process=image/resize,m_lfit,h_340,w_450) There are $3$ ways in total. #### Sample 3 Explanation The valid positions of the fly swatter are as follows: ![](https://cdn.luogu.com.cn/upload/image_hosting/cj9f17kw.png?x-oss-process=image/resize,m_lfit,h_340,w_450) There is $1$ way in total. ### Constraints For $63\%$ of the testdata, $1\le X_p,Y_p\le100$. For $100\%$ of the testdata, $1\le X_p,Y_p\le500,1\le N\le X_p\times Y_p,3\le K\le10^4,0