import sys from collections import deque input = sys.stdin.readline count = 0 h, w = map(int, input().split()) visited = [[False]*w for _ in range(h)] dia = [input().split() for i in range(int(h))] dx = (-1, 0, 1, 0) dy = (0, 1, 0, -1) def bfs(i, j): queue = deque() queue.append((i, j, 0)) visited[i][j] = True num = 0 while queue: x, y, distance = queue.popleft() for k in range(4): nx, ny = x+dx..