You are surveying aerial photographs of Antarctica, looking for evidence of secret (and illegal) oil-drilling rigs, and you must report how many you discover.
You are given a number of scenarios. Each scenario consists of an image of a secret rig and a map of a section of snowfield. Snow is represented by a dot (.) and part of a building by an upper-case X. Count how many times an exact copy of the rig in the image appears on the map. "Exact" means you do not count rotations or mirror images — only copies with the same orientation.
The first line contains a single integer: the number of scenarios.
Each scenario starts with one line containing two positive integers $L_i$ and $C_i$, the number of lines and columns in the image of the rig. Both are in the range 1 to 12 inclusive.
$L_i$ lines follow, each containing $C_i$ characters. Each character is an upper-case X or a dot (.). These lines form the image of the secret rig, trimmed so that there is no unnecessary snow (.) surrounding the rig (X) elements.
The next line contains two more integers $L_m$ and $C_m$, the number of lines and columns of the map to be searched. Both are in the range 1 to 32, with $L_m \ge L_i$ and $C_m \ge C_i$.
$L_m$ lines follow, each containing $C_m$ characters (an upper-case X or a dot). These lines form the map you are to search.
For each scenario, output a single integer on its own line: the number of times the secret rig is found in the map. For a position to match, every cell must agree when the image is overlaid — not only the X (building) cells but also the . (snow) cells of the image must match the map at that position.