import sys s = list(map(int,input().split())) n,m =s[0],s[1] L=[] L3=[] L4=[] i=1 while i <=n: s = list(map(int,input().split())) L.append(s) i+=1 x=[-1,0,1,0] y=[0,-1,0,1] def bfs(i,j,n,m): distance=[[0 for i in range(m+1)] for j in range(n+1)] father = [[0 for i in ...