Mirko soon realised that number sequences are not the best career choice, and went right back to letter table business.
Mirko's table has rows and columns and consists of lowercase letters.
Each cell of the table is a square of equal size. We assign coordinates to vertices of those squares, so that the upper-left corner of the table has coordinates , the upper-right , the lower-left , and the lower-right .
We say that a polygon within the table is monoliteral if the following holds:
- its vertices are from the described set of cell-square vertices,
- its edges are parallel to the coordinate axes,
- all letters inside the polygon are equal.
A simple polygon for which the first two conditions are true (the third one may or may not be true) is given. Mirko would like to know the number of monoliteral polygons that can be obtained by moving the given one up, down, left, or right or any combination thereof, but not rotating.
Input Specification
The first line of input contains two space separated integers and .
Each of the next lines contains exactly lowercase letters, this is Mirko's table.
The following line contains integer , number of vertices of the given polygon.
Each of the next lines contains two integers , . These are the coordinates of the vertices of the given polygon. Vertices are given in clockwise order.
The given polygon will satisfy conditions and from above.
Output Specification
In the first and only line of output, print the expected number of polygons.
Scoring
In test cases worth of total points, , and will not exceed .
In test cases worth of total points, will not exceed .
Sample Input 1
3 3
aaa
aaa
aaa
4
2 0
2 2
0 2
0 0
Sample Output 1
4
Sample Input 2
3 3
aaa
aba
aaa
4
2 0
2 2
0 2
0 0
Sample Output 2
0
Sample Input 3
5 4
xyyx
xyyy
xxyy
xxxx
xxxx
8
1 3
1 2
0 2
0 0
2 0
2 1
3 1
3 3
Sample Output 3
2
Comments