2344: Jangalestan

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:41 解决:21

题目描述

Jangalestan is a country which its map is a n*m  table. Each cell of this table is either empty or there is a tree in it. We call two cells of this table adjacent if they have an edge or vertex in common. We say there is a path between two trees in the  cells (is,js) and (if,jf) of this table if there is a sequence  of the table cells such that each element of this sequence is adjacent to its previous and next elements. A city in Jangalestan is a maximal set of trees such that each pair of trees in the set has a path to each others.

You are given the map of Jangalestan. You should find the number of cities in Jangalestan.

输入

First line of Inputs contains number of the tests.

For each test case, first you are given 1<=m<=100 and 1<=n<=100  the number of rows and columns in Jangalestan’s plan. Then, in the next  m line, in each line you are given n  character. Character ‘@’ means that there is a tree in that cell and character ‘*’ shows that it’s an empty cell.

输出

For each test case output the number of cities in Jangalestan.

样例输入 复制

2
2 3
*@*
@**
4 4
***@
@***
***@
*@@@

样例输出 复制

1
3

来源/分类