beecrowd | 2371
# Naval Battle

**Timelimit: 1**

OBI - Olimpíada Brasileira de Informática 2010 Brazil

Pedro and Paulo love to play Naval Battle; despite being good friends, Pedro suspects that Paulo is not playing honestly. To fix this, Pedro decided to use a computer program to verify the game result, but he doesn't know how to program so he asked for your help. The naval battle it's a board game with **N** lines and **M** columns. Each position in this board is a square that can contain water or a ship piece. Two squares are neighbors if they have a side in common. If both ship parts are on neighbors then these pieces belong to the same ship. One rule forbids that two different ships share a single ship part (in other words, the squares of two different ship parts are in the same position). Each shot that one player does must be thrown at the board of the other player. The other player tells the other the line and column where he wants to shoot. To destroy a ship, the player must hit all its ship pieces. A player mustn't shoot in the same place twice.

Write a program that, given the information about the board and the shots given by the player, determines the number of ships that were destroyed.

The first input line contains two integers **N** and **M** (1 ≤ **N** ≤ 100 e **M** ≤ 100), representing respectively the number of lines and columns of the board. The next **N** lines correspond to the board game. Each of these lines contain **M** characters. Each character indicates the content of the position of the board. If this character is '.', then this position contains water; if it's '#', this position contains a ship piece. The next line contains a number **K** with the number of the shots given by the player (1 ≤ **K** ≤ **N** × **M**). The next **K** lines contain two integers **L** and **C, **indicating the the line and column of the shot made by the other player (1 ≤ **L** ≤ **N** e 1 ≤ **C** ≤ **M**).

Your program must print a single line containing an integer, the number of the ships destroyed. Be careful that when one group of test cases that totalizes 30 points, the ships are composed by one piece (or a square position) and if it totalizes 50 points, each ship is contained exactly within one line.

Input Samples | Output Samples |

5 5 |
4 |

5 5 |
2 |

7 7 |
1 |