#include <stdio.h>
#include <string.h>
#define MAXN 240
int map[MAXN][MAXN];
int visit[MAXN][MAXN];
int ok, ans, count, cur;
int w, h;
void dfs(int x, int y);
int main()
{
int i, j;
char ch;
int tests = 0;
#ifndef ONLINE_JUDGE
freopen("d:\\uva_in.txt", "r", stdin);
#endif
while (scanf("%d%d", &w, &h) && (w != 0 || h != 0))
{
memset(map, 0, sizeof(map));
memset(visit, 0, sizeof(visit));
count = 0;
ans = -1;
fgetc(stdin);
for (i = 0; i < h * 3; i += 3)
{
for (j = 0; j < w * 3; j += 3)
{
scanf("%c", &ch);
if (ch == '\\')
map[i][j] = map[i + 1][j + 1] = map[i + 2][j + 2] = 1;
else if (ch == '/')
map[i][j + 2] = map[i + 1][j + 1] = map[i + 2][j] = 1;
}
fgetc(stdin);
}
for (i = 0; i < h * 3; i++)
{
for (j = 0; j < w * 3; j++)
{
if (!visit[i][j] && !map[i][j])
{
cur = 0;
ok = 1;
dfs(i, j);
if (ok)
{
if (cur > ans)
ans = cur;
count++;
}
}
}
}
printf("Maze #%d:\n", ++tests);
if (count)
{
printf("%d Cycles; the longest has length %d.\n\n", count, ans / 3);
} else
{
printf("There are no cycles.\n\n");
}
}
return 0;
}
void dfs(int x, int y)
{
if (x < 0 || y < 0 || x > h * 3 || y > w * 3)
{
ok = 0;
return;
}
if (visit[x][y] || map[x][y])
return;
visit[x][y] = 1;
cur++;
dfs(x, y + 1);
dfs(x, y - 1);
dfs(x + 1, y);
dfs(x - 1, y);
}