import sys sys.setrecursionlimit(10**4) h,w=map(int,input().split()) g=[list(map(int,input().split())) for _ in range(h)] def dfs(i,j): g[i][j]=0 dy=[0,1,0,-1] dx=[1,0,-1,0] for k in range(4): y=i+dy[k] x=j+dx[k] if not(0<=y