Bradley has recently been addicted to this game of Disco Zoo.
In this game, there is a rescue portion, where you have to "go to the forest" to "rescue animals". Each animal has a specific pattern. For example, in the example you see above, the rabbit has a pattern of four in a vertical column. Bradley, playing a variant of this game, is "rescuing animals" in a grid of size H x W, and is attempting to find one animal of a specific pattern (possibly the one you see above). In addition, Bradley has also explored some grid squares and found no animals to be there, thus the pattern of that animal cannot enter into those squares. Given a grid containing the pattern of the animal Bradley is finding, and another grid representing the area Bradley has explored (or not explored), Bradley wonders how many possible positions the animals can possibly be in.
The first line of input contains two integers, H
The next H
lines of W
characters contains either a '.' or a 'X', with a 'X' representing an area Bradley has explored and an '.' representing otherwise.
The following line of input contains two integers, A
, the height and width of the grid that will contain one
pattern of the animal Bradley is trying to find.
The next A
lines of input will contain B
characters each, being either a '.' or an 'A', with a '.' representing an empty area while an 'A' represents a grid that is part of the animal pattern.
Please note that the animal's shape will always be convex and may not cover the entire grid.
Your output should contain one integer, the number of possible positions the animal could still possibly be in.
Subtask 1 (24%): 1 ≤ H, W, A, B ≤ 10.
Subtask 2 (27%): 1 ≤ H, W, A, B ≤ 100.
Subtask 3 (49%): 1 ≤ H, W, A, B ≤ 1000.
Subtask 4 (0%): As per sample testcases.
Sample Input 1
Sample Output 1
Explanation for Sample 1