One day, Patrick is curious about how many flower-like cloud are there in the picture he took. He tried to count them himself, but it is so difficult for him to count one after one. Smart Squidward tell him that it is possible to count easier by the follwing method:
1. You need a image (e.g. sky picture) that each pixel contains only 0(black) and 1(white), which is also called as binary image
2. Obtain another image that describe the pattern you are curious about
3. Scanning through the whole binary image with the pattern image to count the amount of the desired pattern
For example,
Given the binary image:
, which can represent as a matrix:
1 0 1 0 0
0 1 0 1 0
0 0 1 0 1
1 1 0 0 0
0 0 1 0 0
and the pattern image:
, which can represent as a matrix:
1 0 0
0 1 0
0 0 1
then the amount of the desire pattern is 2.
The first line contains one integer n (2 ≤ n ≤ 20) – the size of the binary matrix.
Then the following n * n numbers are the value of this matrix, the value is either 0 or 1.
Then the next line will contains one integer m (2 ≤ m ≤ n ) – the size of the patten matrix.
Finally, the following m * m numbers are the value of this matrix, the value is either 0 or 1.
The amount of the desire pattern.
You need to print a newline character at the end. ('\n')