1043 - IMMVP   

Description

  The Evil Terran, Dreamoon Zero, is going to attack our planet!

As a smart cerebrate, you have dispatched the scouts for discover the status of the enemies. You discovered that the force of enemies are all small vanguards composed by “marine”, so the best way to bear them up is using the “baneling landmine”!

“Baneling” can see as a remote-controlled bomb, it can kill the enemies who are in the range of two blocks from the boom.

You propose to kill all Dreamoon’s vanguards by “baneling”, then Dreamoon probably cannot dispatch new troop to attack such that you can discuss the plan to defeat Dreamoon with other cerebrates.

Of course, you hope use the least “baneling” to ***** the goal.


Input

There are multiple test data, for each test data:

The first line contains two integer, H and W. (1 ≤ H, W ≤ 50 )

The following H lines, each line contains W characters, are meaning that the lineup of the enemies, “m” means “Marine” and “.” means nothing.

The next line contains a integer H’ (1 ≤ H’ ≤ 50) that you can have H’ x W sized place to put “Baneling”.

And the following H’ lines, each line contains W characters, are meaning that your place, ‘X’ means that the soil is too hard to put “Baneling” and “.” means you can put “Baneling” completely.

The enemies will move forward(v) by the speed of 1 block/second, you can control the time of the explosion of each baneling freely.

A block can put more than 1 “Baneling” and the explosion will not effect on other “Baneling”.

By the way, there are at most twenty marines.


Output

For each test case, output a line contains a integer that the minimum number of “Baneling” to kill all the enemies. If we cannot do it, please output “impossible”(Do need output the symbol of the double quote.)

 

Sample Input  Download

Sample Output  Download

Tags




Discuss